Return salt data via email
The following fields can be set in the minion conf file:
smtp.from (required)
smtp.to (required)
smtp.host (required)
smtp.port (optional, defaults to 25)
smtp.username (optional)
smtp.password (optional)
smtp.tls (optional, defaults to False)
smtp.subject (optional, but helpful)
smtp.gpgowner (optional)
smtp.fields (optional)
smtp.template (optional)
smtp.renderer (optional)
Alternative configuration values can be used by prefacing the configuration. Any values not found in the alternative configuration will be pulled from the default location:
alternative.smtp.from
alternative.smtp.to
alternative.smtp.host
alternative.smtp.port
alternative.smtp.username
alternative.smtp.password
alternative.smtp.tls
alternative.smtp.subject
alternative.smtp.gpgowner
alternative.smtp.fields
alternative.smtp.template
alternative.smtp.renderer
There are a few things to keep in mind:
If a username is used, a password is also required. It is recommended (but not required) to use the TLS setting when authenticating.
You should at least declare a subject, but you don't have to.
The use of encryption, i.e. setting gpgowner in your settings, requires python-gnupg to be installed.
The field gpgowner specifies a user's ~/.gpg directory. This must contain a gpg public key matching the address the mail is sent to. If left unset, no encryption will be used.
smtp.fields lets you include the value(s) of various fields in the subject line of the email. These are comma-delimited. For instance:
smtp.fields: id,fun
...will display the id of the minion and the name of the function in the subject line. You may also use 'jid' (the job id), but it is generally recommended not to use 'return', which contains the entire return data structure (which can be very large). Also note that the subject is always unencrypted.
To use the SMTP returner, append '--return smtp' to the salt command.
salt '*' test.ping --return smtp
To use the alternative configuration, append '--return_config alternative' to the salt command.
2015.5.0 新版功能.
salt '*' test.ping --return smtp --return_config alternative
To override individual configuration items, append --return_kwargs '{"key:": "value"}' to the salt command.
2016.3.0 新版功能.
salt '*' test.ping --return smtp --return_kwargs '{"to": "user@domain.com"}'
salt.returners.smtp_return.
prep_jid
(nocache=False, passed_jid=None)¶Do any work necessary to prepare a JID, including sending a custom id
salt.returners.smtp_return.
returner
(ret)¶Send an email with the data