Skip to content

Commit

Permalink
Fixes #24399 - Drop email configuration via files
Browse files Browse the repository at this point in the history
This has been deprecated since 1.14 and removed in 1.16.
  • Loading branch information
ekohl authored and mmoll committed Aug 2, 2018
1 parent d2b3657 commit e6ead45
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 80 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ previous stable release.
### Foreman version compatibility notes

For Foreman 1.16 or older, please set the `dynflow_in_core` parameter to false.
For Foreman 1.11 or older, please use the 5.x release series of this module.
For Foreman 1.13 or older, please use the 5.x release series of this module.

## Types and providers

Expand Down
17 changes: 3 additions & 14 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,9 @@
content => template('foreman/database.yml.erb'),
}

if $::foreman::email_delivery_method and !empty($::foreman::email_delivery_method) {
if $::foreman::email_config_method == 'file' {
file { "/etc/foreman/${foreman::email_conf}":
ensure => file,
owner => 'root',
group => $::foreman::group,
mode => '0640',
content => template("foreman/${foreman::email_source}"),
}
} else {
file { "/etc/foreman/${foreman::email_conf}":
ensure => absent,
}
}
# email.yaml support has been removed in 1.16.
file { '/etc/foreman/email.yaml':
ensure => absent,
}

file { $::foreman::init_config:
Expand Down
9 changes: 0 additions & 9 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@
#
# === Advanced parameters:
#
# $email_source:: Template to use for email configuration file
#
# $foreman_url:: URL on which foreman is going to run
#
# $unattended:: Should Foreman manage host provisioning as well
Expand Down Expand Up @@ -201,10 +199,6 @@
#
# $loggers:: Enable or disable specific loggers, e.g. {"sql" => true}
#
# $email_config_method:: Configure email settings in database (1.14+) or configuration file (deprecated)
#
# $email_conf:: Email configuration file under /etc/foreman
#
# $telemetry_prefix:: Prefix for all metrics
#
# $telemetry_prometheus_enabled:: Enable prometheus telemetry
Expand Down Expand Up @@ -313,9 +307,6 @@
Enum['file', 'syslog', 'journald'] $logging_type = $::foreman::params::logging_type,
Enum['pattern', 'multiline_pattern', 'json'] $logging_layout = $::foreman::params::logging_layout,
Hash[String, Boolean] $loggers = $::foreman::params::loggers,
Enum['database', 'file'] $email_config_method = $::foreman::params::email_config_method,
String $email_conf = $::foreman::params::email_conf,
String $email_source = $::foreman::params::email_source,
Optional[Enum['sendmail', 'smtp']] $email_delivery_method = $::foreman::params::email_delivery_method,
Optional[String] $email_smtp_address = $::foreman::params::email_smtp_address,
Integer[0, 65535] $email_smtp_port = $::foreman::params::email_smtp_port,
Expand Down
3 changes: 0 additions & 3 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@
$db_manage_rake = true

# Configure foreman email settings (database or email.yaml)
$email_config_method = 'file'
$email_conf = 'email.yaml'
$email_source = 'email.yaml.erb'
$email_delivery_method = undef
$email_smtp_address = undef
$email_smtp_port = 25
Expand Down
3 changes: 1 addition & 2 deletions manifests/settings.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Configure settings in Foreman's database
class foreman::settings(
$email_config_method = $::foreman::email_config_method,
$email_delivery_method = $::foreman::email_delivery_method,
$email_smtp_address = $::foreman::email_smtp_address,
$email_smtp_port = $::foreman::email_smtp_port,
Expand All @@ -9,7 +8,7 @@
$email_smtp_user_name = $::foreman::email_smtp_user_name,
$email_smtp_password = $::foreman::email_smtp_password,
) {
if $email_config_method == 'database' and !empty($email_delivery_method) {
unless empty($email_delivery_method) {
foreman_config_entry { 'delivery_method':
value => $email_delivery_method,
}
Expand Down
33 changes: 5 additions & 28 deletions spec/classes/foreman_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@
})
end

it { should_not contain_file('/etc/foreman/email.yaml') }

case facts[:osfamily]
when 'RedHat'
it 'should set the defaults file' do
Expand Down Expand Up @@ -246,11 +244,9 @@ class {'foreman':
}"
end

it 'should contain email.yaml with SMTP set' do
should contain_file('/etc/foreman/email.yaml').
with_content(/delivery_method: :smtp/).
with_ensure('file')
end
it { should contain_file('/etc/foreman/email.yaml').with_ensure('absent') }
it { should contain_foreman_config_entry('delivery_method').with_value('smtp') }
it { should contain_foreman_config_entry('smtp_authentication').with_value('') }
end

describe 'with email configured and authentication set to login' do
Expand All @@ -261,11 +257,7 @@ class {'foreman':
}"
end

it 'should contain email.yaml with login authentication' do
should contain_file('/etc/foreman/email.yaml').
with_content(/authentication: :login/).
with_ensure('file')
end
it { should contain_foreman_config_entry('smtp_authentication').with_value('login') }
end

describe 'with email configured for sendmail' do
Expand All @@ -275,22 +267,7 @@ class {'foreman':
}"
end

it 'should contain email.yaml with sendmail' do
should contain_file('/etc/foreman/email.yaml').
with_content(/delivery_method: :sendmail/).
with_ensure('file')
end
end

describe 'with email configured in the database' do
let :pre_condition do
"class {'foreman':
email_config_method => 'database',
email_delivery_method => 'sendmail',
}"
end

it { should contain_file('/etc/foreman/email.yaml').with_ensure('absent') }
it { should contain_foreman_config_entry('delivery_method').with_value('sendmail') }
end

if Puppet.version >= '4.0'
Expand Down
6 changes: 0 additions & 6 deletions spec/classes/foreman_settings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
context "on #{os}" do
let(:facts) { facts }
let(:sample_params) do {
email_config_method: 'database',
email_delivery_method: 'sendmail',
email_smtp_address: 'smtp.example.com',
email_smtp_port: 25,
Expand All @@ -26,11 +25,6 @@
it { should contain_foreman_config_entry('smtp_password').with_value('smtp-password') }
end

context 'with email_config_method=file' do
let(:params) { sample_params.merge(email_config_method: 'file') }
it { should_not contain_foreman_config_entry('delivery_method') }
end

context 'with email_smtp_authentication=cram-md5' do
let(:params) { sample_params.merge(email_smtp_authentication: 'cram-md5') }
it { should contain_foreman_config_entry('smtp_authentication').with_value('cram-md5') }
Expand Down
2 changes: 0 additions & 2 deletions spec/classes/foreman_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ class { 'foreman::providers':
:websockets_ssl_cert => '/etc/ssl/certs/snakeoil.pem',
:logging_level => 'info',
:loggers => {},
:email_conf => 'email.yaml',
:email_source => 'email.yaml.erb',
:email_delivery_method => 'sendmail',
:email_smtp_address => 'alice@bob.com',
:email_smtp_port => 25,
Expand Down
15 changes: 0 additions & 15 deletions templates/email.yaml.erb

This file was deleted.

0 comments on commit e6ead45

Please sign in to comment.