Skip to content
This repository has been archived by the owner on Jun 21, 2018. It is now read-only.

add email_host parameter #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ An empty string forces the output to stdio, so emails will be sent by crond
Sender email address for update notifications. No effect when `email_to` is empty. Defaults to `root` (local user)
*Note:* not supported on CentOS 5

##### `email_host`
Email host address for update notifications. No effect when `email_to` is empty. Defaults to `localhost`
*Note:* not supported on CentOS 5 and CentOS 6

##### `debug_level`
YUM debug level. Valid values are numbers between `-1` and `10`. `-1` to disable. Default depends on the platform
Enforced to `-1` when `notify_email` is `false`
Expand Down
5 changes: 4 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
# recipient email address for update notifications. No effect when $notify_email is false
# [*email_from*]
# sender email address for update notifications. No effect when $email_to is empty
# [*email_host*]
# email host address for sending update notifications. No effect when $email_to is empty
# [*debug_level*]
# YUM debug level (valid: 0-10 or -1). -1 to disable debug output completely
# [*error_level*]
Expand Down Expand Up @@ -63,6 +65,7 @@
$notify_email = true,
$email_to = 'root',
$email_from = 'root',
$email_host = 'localhost',
$debug_level = $yum_autoupdate::params::debug_level,
$error_level = 0,
$skip_broken = false,
Expand All @@ -74,7 +77,7 @@
validate_bool($service_enable, $notify_email, $default_schedule, $keep_default_hourly, $skip_broken)
validate_re($action, '^(check|download|apply)$', '$action must be either \'check\', \'download\' or \'apply\'')
validate_array($exclude)
validate_string($email_to, $email_from, $update_cmd)
validate_string($email_to, $email_from, $email_host, $update_cmd)
if ($debug_level < -1) or ($debug_level > 10) { fail('$debug_level must be a number between -1 and 10') }
if ($error_level < 0) or ($error_level > 10) { fail('$error_level must be a number between 0 and 10') }
validate_re($update_cmd, '^(default|security|security-severity:Critical|minimal|minimal-security|minimal-security-severity:Critical)$', '$update_cmd must be either \'default\', \'security\', \'security-severity:Critical\', \'minimal\', \'minimal-security\' or \'minimal-security-severity:Critical\'')
Expand Down
5 changes: 4 additions & 1 deletion manifests/schedule.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# recipient email address for update notifications. No effect when $notify is false
# [*email_from*]
# sender email address for update notifications. No effect when $email_to is empty
# [*email_host*]
# email host address for sending update notifications. No effect when $email_to is empty
# [*debug_level*]
# YUM debug level (valid: 0-10 or -1). -1 to disable debug output completely
# [*error_level*]
Expand Down Expand Up @@ -62,6 +64,7 @@
$notify_email = true,
$email_to = 'root',
$email_from = 'root',
$email_host = 'localhost',
$debug_level = $yum_autoupdate::params::debug_level,
$error_level = 0,
$skip_broken = false,
Expand All @@ -84,7 +87,7 @@
validate_re($action, '^(check|download|apply)$', '$action must be either \'check\', \'download\' or \'apply\'')
validate_array($exclude)
validate_bool($notify_email, $skip_broken)
validate_string($email_to, $email_from, $update_cmd)
validate_string($email_to, $email_from, $email_host, $update_cmd)
if ($debug_level < -1) or ($debug_level > 10) { fail('$debug_level must be a number between -1 and 10') }
if ($error_level < 0) or ($error_level > 10) { fail('$error_level must be a number between 0 and 10') }
validate_re($update_cmd, '^(default|security|security-severity:Critical|minimal|minimal-security|minimal-security-severity:Critical)$', '$update_cmd must be either \'default\', \'security\', \'security-severity:Critical\', \'minimal\', \'minimal-security\' or \'minimal-security-severity:Critical\'')
Expand Down
3 changes: 2 additions & 1 deletion spec/classes/yum_autoupdate_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@
'notify_email' => false,
'email_to' => '[email protected]',
'email_from' => 'updates@localhost',
'email_host' => 'smtp.example.com',
'debug_level' => 4,
'error_level' => 2,
'skip_broken' => true,
Expand Down Expand Up @@ -276,7 +277,7 @@
end
context 'on new generation' do
it 'expect valid content' do
is_expected.to contain_file('yum-cron default config').with_content("# ******************\n# Managed by Puppet\n# ******************\n\n[commands]\nupdate_cmd = security\nupdate_messages = no\ndownload_updates = no\napply_updates = no\nrandom_sleep = 120\n\n[emitters]\nsystem_name = None\nemit_via = email\noutput_width = 80\n\n[email]\nemail_from = updates@localhost\nemail_to = [email protected]\nemail_host = localhost\n\n[groups]\ngroup_list = None\ngroup_package_types = mandatory, default\n\n[base]\ndebuglevel = -1\nerrorlevel = 2\nskip_broken = True\nmdpolicy = group:main\n# assumeyes = True\nexclude=httpd kernel\n")
is_expected.to contain_file('yum-cron default config').with_content("# ******************\n# Managed by Puppet\n# ******************\n\n[commands]\nupdate_cmd = security\nupdate_messages = no\ndownload_updates = no\napply_updates = no\nrandom_sleep = 120\n\n[emitters]\nsystem_name = None\nemit_via = email\noutput_width = 80\n\n[email]\nemail_from = updates@localhost\nemail_to = [email protected]\nemail_host = smtp.example.com\n\n[groups]\ngroup_list = None\ngroup_package_types = mandatory, default\n\n[base]\ndebuglevel = -1\nerrorlevel = 2\nskip_broken = True\nmdpolicy = group:main\n# assumeyes = True\nexclude=httpd kernel\n")
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion spec/defines/schedule_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@
'notify_email' => false,
'email_to' => '[email protected]',
'email_from' => 'updates@localhost',
'email_host' => 'smtp.example.com',
'debug_level' => 4,
'error_level' => 2,
'skip_broken' => true,
Expand Down Expand Up @@ -225,7 +226,7 @@
end
context 'on new generation' do
it 'expect valid content' do
is_expected.to contain_file('yum-cron rspec_hourly config').with_content("# ******************\n# Managed by Puppet\n# ******************\n\n[commands]\nupdate_cmd = security\nupdate_messages = no\ndownload_updates = no\napply_updates = no\nrandom_sleep = 120\n\n[emitters]\nsystem_name = None\nemit_via = email\noutput_width = 80\n\n[email]\nemail_from = updates@localhost\nemail_to = [email protected]\nemail_host = localhost\n\n[groups]\ngroup_list = None\ngroup_package_types = mandatory, default\n\n[base]\ndebuglevel = -1\nerrorlevel = 2\nskip_broken = True\nmdpolicy = group:main\n# assumeyes = True\nexclude=httpd kernel\n")
is_expected.to contain_file('yum-cron rspec_hourly config').with_content("# ******************\n# Managed by Puppet\n# ******************\n\n[commands]\nupdate_cmd = security\nupdate_messages = no\ndownload_updates = no\napply_updates = no\nrandom_sleep = 120\n\n[emitters]\nsystem_name = None\nemit_via = email\noutput_width = 80\n\n[email]\nemail_from = updates@localhost\nemail_to = [email protected]\nemail_host = smtp.example.com\n\n[groups]\ngroup_list = None\ngroup_package_types = mandatory, default\n\n[base]\ndebuglevel = -1\nerrorlevel = 2\nskip_broken = True\nmdpolicy = group:main\n# assumeyes = True\nexclude=httpd kernel\n")
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion templates/conf/rhel7.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ output_width = 80
[email]
email_from = <%= @email_from %>
email_to = <%= @email_to %>
email_host = localhost
email_host = <%= @email_host %>

[groups]
group_list = None
Expand Down