diff --git a/README.md b/README.md index 9a71b0b3..49c9ea52 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,8 @@ altering some of the default settings. xenial, bionic and default), `false` for Debian (wheezy and default)): Use the legacy `Unattended-Upgrade::Allowed-Origins` setting or the modern `Unattended-Upgrade::Origins-Pattern`. * `mail`: A hash to configure email behaviour with two possible keys: - * `only_on_error` (`true`): Only send mail when something went wrong + * `report` (`undef`): Possible values are "always", "only-on-error" or "on-change". Defaults to "on-change". Note that "never" is achieved by not setting any `to` address. + * `only_on_error` (`true`): Only send mail when something went wrong. Deprecated in unattended-upgrades 1.13 and newer in favor of `report`. * `to` (`undef`): Email address to send email too If the default for `to` is kept you will not receive any mail at all. You'll diff --git a/spec/classes/unattended_upgrades_spec.rb b/spec/classes/unattended_upgrades_spec.rb index 1f19a4fe..e38d16ff 100644 --- a/spec/classes/unattended_upgrades_spec.rb +++ b/spec/classes/unattended_upgrades_spec.rb @@ -71,7 +71,8 @@ install_on_shutdown: true, mail: { 'to' => 'root@localhost', - 'only_on_error' => true + 'only_on_error' => true, + 'report' => 'on-change', }, sender: 'root@server.example.com', dl_limit: 70, @@ -138,6 +139,8 @@ /Unattended-Upgrade::Sender "root@server.example.com";/ ).with_content( /Unattended-Upgrade::MailOnlyOnError "true";/ + ).with_content( + /Unattended-Upgrade::MailReport "on-change";/ ).with_content( /Acquire::http::Dl-Limit "70";/ ).with_content( diff --git a/templates/unattended-upgrades.erb b/templates/unattended-upgrades.erb index 6d1e633c..dc7251fb 100644 --- a/templates/unattended-upgrades.erb +++ b/templates/unattended-upgrades.erb @@ -63,6 +63,13 @@ Unattended-Upgrade::Mail "<%= @_mail['to'] %>"; // is to always send a mail if Unattended-Upgrade::Mail is set Unattended-Upgrade::MailOnlyOnError "<%= @_mail['only_on_error'].to_s %>"; <%- end -%> +<%- if @_mail['report'] -%> +// Set this value to one of: +// "always", "only-on-error" or "on-change" +// If this is not set, then any legacy MailOnlyOnError (boolean) value +// is used to chose between "only-on-error" and "on-change" +Unattended-Upgrade::MailReport "<%= @_mail['report'] %>"; +<%- end -%> <%- end -%> <%- if @sender -%> diff --git a/types/mail.pp b/types/mail.pp index 329d5156..b615a7b6 100644 --- a/types/mail.pp +++ b/types/mail.pp @@ -1,5 +1,6 @@ type Unattended_upgrades::Mail = Struct[ { + Optional['report'] => String, Optional['only_on_error'] => Boolean, Optional['to'] => String, }