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 support for Puppet 8 #358

Merged
merged 2 commits into from
Jun 16, 2023
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
2 changes: 1 addition & 1 deletion data/osfamily/Suse/11.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
postfix::params::restart_cmd: '/etc/init.d/postfix reload'
postfix::params::master_os_template: "postfix/master.cf.SLES%{::operatingsystemrelease}.erb"
postfix::params::master_os_template: "postfix/master.cf.SLES%{facts.os.release.full}.erb"
...
4 changes: 2 additions & 2 deletions hiera.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ hierarchy:

- name: "Per-OS family"
paths:
- "osfamily/%{facts.os.family}/%{facts.lsbdistcodename}.yaml"
- "osfamily/%{facts.os.family}/%{facts.operatingsystemmajrelease}.yaml"
- "osfamily/%{facts.os.family}/%{facts.os.distro.codename}.yaml"
- "osfamily/%{facts.os.family}/%{facts.os.release.major}.yaml"
- "osfamily/%{facts.os.family}.yaml"

- name: "Common data"
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"requirements": [
{
"name": "puppet",
"version_requirement": ">= 7.0.0 < 8.0.0"
"version_requirement": ">= 7.0.0 < 9.0.0"
}
]
}
8 changes: 4 additions & 4 deletions spec/acceptance/postfix_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
it 'works idempotently with no errors' do
pp = <<-EOS
# Make sure the default mailer is stopped in docker containers
if $::operatingsystem == 'Debian' {
if fact('os.name') == 'Debian' {
service { 'exim4':
ensure => stopped,
hasstatus => false,
before => Class['postfix'],
}
}
if $::osfamily == 'RedHat' {
if fact('os.family') == 'RedHat' {
service { 'sendmail':
ensure => stopped,
hasstatus => false,
Expand Down Expand Up @@ -50,14 +50,14 @@ class { 'postfix':
it 'works idempotently with no errors and with your own configuration of /etc/aliases' do
pp = <<-EOS
# Make sure the default mailer is stopped in docker containers
if $::operatingsystem == 'Debian' {
if fact('os.name') == 'Debian' {
service { 'exim4':
ensure => stopped,
hasstatus => false,
before => Class['postfix'],
}
}
if $::osfamily == 'RedHat' {
if fact('os.family') == 'RedHat' {
service { 'sendmail':
ensure => stopped,
hasstatus => false,
Expand Down
24 changes: 12 additions & 12 deletions spec/classes/postfix_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,31 @@
on_supported_os.each do |os, facts|
context "on #{os}" do # rubocop:disable RSpec/MultipleMemoizedHelpers
let(:postfix_main_cf_path) do
case facts[:osfamily]
case facts[:os]['family']
when 'FreeBSD' then '/usr/local/etc/postfix/main.cf'
else '/etc/postfix/main.cf'
end
end
let(:postfix_master_cf_path) do
case facts[:osfamily]
case facts[:os]['family']
when 'FreeBSD' then '/usr/local/etc/postfix/master.cf'
else '/etc/postfix/master.cf'
end
end
let(:postfix_transport_path) do
case facts[:osfamily]
case facts[:os]['family']
when 'FreeBSD' then '/usr/local/etc/postfix/transport'
else '/etc/postfix/transport'
end
end
let(:postfix_virtual_path) do
case facts[:osfamily]
case facts[:os]['family']
when 'FreeBSD' then '/usr/local/etc/postfix/virtual'
else '/etc/postfix/virtual'
end
end
let(:postfix_path) do
case facts[:osfamily]
case facts[:os]['family']
when 'FreeBSD' then '/usr/local/etc/postfix'
else '/etc/postfix'
end
Expand Down Expand Up @@ -60,7 +60,7 @@
it { is_expected.to contain_augeas("manage postfix 'inet_interfaces'").with_changes("set inet_interfaces 'all'") }
it { is_expected.to contain_augeas("manage postfix 'inet_protocols'").with_changes("set inet_protocols 'all'") }

context 'when on Debian family', if: facts[:osfamily] == 'Debian' do # rubocop:disable RSpec/MultipleMemoizedHelpers
context 'when on Debian family', if: facts[:os]['family'] == 'Debian' do # rubocop:disable RSpec/MultipleMemoizedHelpers
it { is_expected.to contain_package('mailx') }
it { is_expected.to contain_file('/etc/mailname').without('seltype').with_content("foo.example.com\n") }
it { is_expected.to contain_file('/etc/aliases').without('seltype').with_content("# file managed by puppet\n") }
Expand All @@ -77,7 +77,7 @@
}
end

context 'when on RedHat family', if: facts[:osfamily] == 'RedHat' do # rubocop:disable RSpec/MultipleMemoizedHelpers
context 'when on RedHat family', if: facts[:os]['family'] == 'RedHat' do # rubocop:disable RSpec/MultipleMemoizedHelpers
it { is_expected.to contain_package('mailx') }
it { is_expected.to contain_file('/etc/mailname').with_seltype('postfix_etc_t').with_content("foo.example.com\n") }
it { is_expected.to contain_file(postfix_master_cf_path).with_seltype('postfix_etc_t') }
Expand All @@ -91,7 +91,7 @@
it { is_expected.to contain_augeas("manage postfix 'mailq_path'") }
it { is_expected.to contain_alternatives('mta') }

context 'when on release 8', if: (facts[:osfamily] == 'RedHat' && facts[:operatingsystemmajrelease] == '8') do # rubocop:disable RSpec/MultipleMemoizedHelpers
context 'when on release 8', if: (facts[:os]['family'] == 'RedHat' && facts[:operatingsystemmajrelease] == '8') do # rubocop:disable RSpec/MultipleMemoizedHelpers
it { is_expected.to contain_file('/etc/aliases').with_seltype('etc_aliases_t').with_content("# file managed by puppet\n") }

it {
Expand All @@ -104,7 +104,7 @@
}
end

context 'when on release 7', if: (facts[:osfamily] == 'RedHat' && facts[:operatingsystemmajrelease] == '7') do # rubocop:disable RSpec/MultipleMemoizedHelpers
context 'when on release 7', if: (facts[:os]['family'] == 'RedHat' && facts[:operatingsystemmajrelease] == '7') do # rubocop:disable RSpec/MultipleMemoizedHelpers
it { is_expected.to contain_file('/etc/aliases').with_seltype('etc_aliases_t').with_content("# file managed by puppet\n") }

it {
Expand All @@ -117,7 +117,7 @@
}
end

context 'when on release 6', if: (facts[:osfamily] == 'RedHat' && facts[:operatingsystemmajrelease] == '6') do # rubocop:disable RSpec/MultipleMemoizedHelpers
context 'when on release 6', if: (facts[:os]['family'] == 'RedHat' && facts[:operatingsystemmajrelease] == '6') do # rubocop:disable RSpec/MultipleMemoizedHelpers
it { is_expected.to contain_file('/etc/aliases').with_seltype('etc_aliases_t').with_content("# file managed by puppet\n") }

it {
Expand All @@ -131,7 +131,7 @@
end
end

context 'when on Fedora', if: facts[:operatingsystem] == 'Fedora' do # rubocop:disable RSpec/MultipleMemoizedHelpers
context 'when on Fedora', if: facts[:os]['name'] == 'Fedora' do # rubocop:disable RSpec/MultipleMemoizedHelpers
it { is_expected.to contain_file('/etc/aliases').with_seltype('etc_aliases_t').with_content("# file managed by puppet\n") }

it {
Expand Down Expand Up @@ -247,7 +247,7 @@
is_expected.to contain_file("#{postfix_path}/ldap-aliases.cf")
end

context 'when on Debian family', if: facts[:osfamily] == 'Debian' do # rubocop:disable RSpec/MultipleMemoizedHelpers
context 'when on Debian family', if: facts[:os]['family'] == 'Debian' do # rubocop:disable RSpec/MultipleMemoizedHelpers
it { is_expected.to contain_package('postfix-ldap') }
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/defines/postfix_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:postfix_main_cf_path) do
case facts[:osfamily]
case facts[:os]['family']
when 'FreeBSD' then '/usr/local/etc/postfix/main.cf'
else '/etc/postfix/main.cf'
end
Expand Down
2 changes: 1 addition & 1 deletion spec/defines/postfix_map_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:postfix_foo_db_path) do
case facts[:osfamily]
case facts[:os]['family']
when 'FreeBSD' then '/usr/local/etc/postfix/foo.db'
else '/etc/postfix/foo.db'
end
Expand Down
2 changes: 1 addition & 1 deletion spec/defines/postfix_transport_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class { '::postfix': }
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:postfix_transport_path) do
case facts[:osfamily]
case facts[:os]['family']
when 'FreeBSD' then '/usr/local/etc/postfix/transport'
else '/etc/postfix/transport'
end
Expand Down
2 changes: 1 addition & 1 deletion spec/defines/postfix_virtual_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class { '::postfix': }
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:postfix_virutal_path) do
case facts[:osfamily]
case facts[:os]['family']
when 'FreeBSD' then '/usr/local/etc/postfix/virtual'
else '/etc/postfix/virtual'
end
Expand Down