Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add the Unattended-Upgrade::MailReport setting to unattended-upgrades.erb #181

Merged
merged 1 commit into from
Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

‘Two possible keys’?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah, there are now three possible keys. #183 fixes this.

* `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
Expand Down
5 changes: 4 additions & 1 deletion spec/classes/unattended_upgrades_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@
install_on_shutdown: true,
mail: {
'to' => 'root@localhost',
'only_on_error' => true
'only_on_error' => true,
'report' => 'on-change',
},
sender: '[email protected]',
dl_limit: 70,
Expand Down Expand Up @@ -138,6 +139,8 @@
/Unattended-Upgrade::Sender "[email protected]";/
).with_content(
/Unattended-Upgrade::MailOnlyOnError "true";/
).with_content(
/Unattended-Upgrade::MailReport "on-change";/
).with_content(
/Acquire::http::Dl-Limit "70";/
).with_content(
Expand Down
7 changes: 7 additions & 0 deletions templates/unattended-upgrades.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 -%>
Expand Down
1 change: 1 addition & 0 deletions types/mail.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
type Unattended_upgrades::Mail = Struct[
{
Optional['report'] => String,
Optional['only_on_error'] => Boolean,
Optional['to'] => String,
}
Expand Down