master_events.rst 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. .. _event-master_events:
  2. ==================
  3. Salt Master Events
  4. ==================
  5. These events are fired on the Salt Master event bus. This list is **not**
  6. comprehensive.
  7. .. _event-master_auth:
  8. Authentication events
  9. =====================
  10. .. salt:event:: salt/auth
  11. Fired when a minion performs an authentication check with the master.
  12. :var id: The minion ID.
  13. :var act: The current status of the minion key: ``accept``, ``pend``,
  14. ``reject``.
  15. :var pub: The minion public key.
  16. .. note:: Minions fire auth events on fairly regular basis for a number
  17. of reasons. Writing reactors to respond to events through
  18. the auth cycle can lead to infinite reactor event loops
  19. (minion tries to auth, reactor responds by doing something
  20. that generates another auth event, minion sends auth event,
  21. etc.). Consider reacting to ``salt/key`` or ``salt/minion/<MID>/start``
  22. or firing a custom event tag instead.
  23. Start events
  24. ============
  25. .. salt:event:: salt/minion/<MID>/start
  26. Fired every time a minion connects to the Salt master.
  27. :var id: The minion ID.
  28. Key events
  29. ==========
  30. .. salt:event:: salt/key
  31. Fired when accepting and rejecting minions keys on the Salt master.
  32. These happen as a result of actions undertaken by the `salt-key` command.
  33. :var id: The minion ID.
  34. :var act: The new status of the minion key: ``accept``, ``delete``,
  35. .. warning:: If a master is in :conf_master:`auto_accept mode`, ``salt/key`` events
  36. will not be fired when the keys are accepted. In addition, pre-seeding
  37. keys (like happens through :ref:`Salt-Cloud<salt-cloud>`) will not cause
  38. firing of these events.
  39. Job events
  40. ==========
  41. .. salt:event:: salt/job/<JID>/new
  42. Fired as a new job is sent out to minions.
  43. :var jid: The job ID.
  44. :var tgt: The target of the job: ``*``, a minion ID,
  45. ``G@os_family:RedHat``, etc.
  46. :var tgt_type: The type of targeting used: ``glob``, ``grain``,
  47. ``compound``, etc.
  48. :var fun: The function to run on minions: ``test.version``,
  49. ``network.interfaces``, etc.
  50. :var arg: A list of arguments to pass to the function that will be
  51. called.
  52. :var minions: A list of minion IDs that Salt expects will return data for
  53. this job.
  54. :var user: The name of the user that ran the command as defined in Salt's
  55. Publisher ACL or external auth.
  56. .. salt:event:: salt/job/<JID>/ret/<MID>
  57. Fired each time a minion returns data for a job.
  58. :var id: The minion ID.
  59. :var jid: The job ID.
  60. :var retcode: The return code for the job.
  61. :var fun: The function the minion ran. E.g., ``test.version``.
  62. :var return: The data returned from the execution module.
  63. .. salt:event:: salt/job/<JID>/prog/<MID>/<RUN NUM>
  64. Fired each time a each function in a state run completes execution. Must be
  65. enabled using the :conf_master:`state_events` option.
  66. :var data: The data returned from the state module function.
  67. :var id: The minion ID.
  68. :var jid: The job ID.
  69. Runner Events
  70. =============
  71. .. salt:event:: salt/run/<JID>/new
  72. Fired as a runner begins execution
  73. :var jid: The job ID.
  74. :var fun: The name of the runner function, with ``runner.`` prepended to it
  75. (e.g. ``runner.jobs.lookup_jid``)
  76. :var fun_args: The arguments passed to the runner function (e.g.
  77. ``['20160829225914848058']``)
  78. :var user: The user who executed the runner (e.g. ``root``)
  79. .. salt:event:: salt/run/<JID>/ret
  80. Fired when a runner function returns
  81. :var jid: The job ID.
  82. :var fun: The name of the runner function, with ``runner.`` prepended to it
  83. (e.g. ``runner.jobs.lookup_jid``)
  84. :var fun_args: The arguments passed to the runner function (e.g.
  85. ``['20160829225914848058']``)
  86. :var return: The data returned by the runner function
  87. .. salt:event:: salt/run/<JID>/args
  88. .. versionadded:: 2016.11.0
  89. Fired by the :mod:`state.orchestrate <salt.runners.state.orchestrate>`
  90. runner
  91. :var name: The ID declaration for the orchestration job (i.e. the line
  92. above ``salt.state``, ``salt.function``, ``salt.runner``, etc.)
  93. :var type: The type of orchestration job being run (e.g. ``state``)
  94. :var tgt: The target expression (e.g. ``*``). Included for ``state`` and
  95. ``function`` types only.
  96. :var args: The args passed to the orchestration job. **Note:** for
  97. ``state`` and ``function`` types, also includes a ``tgt_type`` value
  98. which shows what kind of match (``glob``, ``pcre``, etc.) was used.
  99. This value was named ``expr_form`` in the 2016.11 release cycle but has
  100. been renamed to ``tgt_type`` in 2017.7.0 for consistency with other
  101. events.
  102. .. _event-master_presence:
  103. Presence Events
  104. ===============
  105. .. salt:event:: salt/presence/present
  106. Events fired on a regular interval about currently connected, newly
  107. connected, or recently disconnected minions. Requires the
  108. :conf_master:`presence_events` setting to be enabled.
  109. :var present: A list of minions that are currently connected to the Salt
  110. master.
  111. .. salt:event:: salt/presence/change
  112. Fired when the Presence system detects new minions connect or disconnect.
  113. :var new: A list of minions that have connected since the last presence
  114. event.
  115. :var lost: A list of minions that have disconnected since the last
  116. presence event.
  117. Cloud Events
  118. ============
  119. Unlike other Master events, ``salt-cloud`` events are not fired on behalf of a
  120. Salt Minion. Instead, ``salt-cloud`` events are fired on behalf of a VM. This
  121. is because the minion-to-be may not yet exist to fire events to or also may have
  122. been destroyed.
  123. This behavior is reflected by the ``name`` variable in the event data for
  124. ``salt-cloud`` events as compared to the ``id`` variable for Salt
  125. Minion-triggered events.
  126. .. salt:event:: salt/cloud/<VM NAME>/creating
  127. Fired when salt-cloud starts the VM creation process.
  128. :var name: the name of the VM being created.
  129. :var event: description of the event.
  130. :var provider: the cloud provider of the VM being created.
  131. :var profile: the cloud profile for the VM being created.
  132. .. salt:event:: salt/cloud/<VM NAME>/deploying
  133. Fired when the VM is available and salt-cloud begins deploying Salt to the
  134. new VM.
  135. :var name: the name of the VM being created.
  136. :var event: description of the event.
  137. :var kwargs: options available as the deploy script is invoked:
  138. ``conf_file``, ``deploy_command``, ``display_ssh_output``, ``host``,
  139. ``keep_tmp``, ``key_filename``, ``make_minion``, ``minion_conf``,
  140. ``name``, ``parallel``, ``preseed_minion_keys``, ``script``,
  141. ``script_args``, ``script_env``, ``sock_dir``, ``start_action``,
  142. ``sudo``, ``tmp_dir``, ``tty``, ``username``
  143. .. salt:event:: salt/cloud/<VM NAME>/requesting
  144. Fired when salt-cloud sends the request to create a new VM.
  145. :var event: description of the event.
  146. :var location: the location of the VM being requested.
  147. :var kwargs: options available as the VM is being requested:
  148. ``Action``, ``ImageId``, ``InstanceType``, ``KeyName``, ``MaxCount``,
  149. ``MinCount``, ``SecurityGroup.1``
  150. .. salt:event:: salt/cloud/<VM NAME>/querying
  151. Fired when salt-cloud queries data for a new instance.
  152. :var event: description of the event.
  153. :var instance_id: the ID of the new VM.
  154. .. salt:event:: salt/cloud/<VM NAME>/tagging
  155. Fired when salt-cloud tags a new instance.
  156. :var event: description of the event.
  157. :var tags: tags being set on the new instance.
  158. .. salt:event:: salt/cloud/<VM NAME>/waiting_for_ssh
  159. Fired while the salt-cloud deploy process is waiting for ssh to become
  160. available on the new instance.
  161. :var event: description of the event.
  162. :var ip_address: IP address of the new instance.
  163. .. salt:event:: salt/cloud/<VM NAME>/deploy_script
  164. Fired once the deploy script is finished.
  165. :var event: description of the event.
  166. .. salt:event:: salt/cloud/<VM NAME>/created
  167. Fired once the new instance has been fully created.
  168. :var name: the name of the VM being created.
  169. :var event: description of the event.
  170. :var instance_id: the ID of the new instance.
  171. :var provider: the cloud provider of the VM being created.
  172. :var profile: the cloud profile for the VM being created.
  173. .. salt:event:: salt/cloud/<VM NAME>/destroying
  174. Fired when salt-cloud requests the destruction of an instance.
  175. :var name: the name of the VM being created.
  176. :var event: description of the event.
  177. :var instance_id: the ID of the new instance.
  178. .. salt:event:: salt/cloud/<VM NAME>/destroyed
  179. Fired when an instance has been destroyed.
  180. :var name: the name of the VM being created.
  181. :var event: description of the event.
  182. :var instance_id: the ID of the new instance.