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 sles10 support #22

Merged
merged 10 commits into from
Nov 23, 2016
18 changes: 5 additions & 13 deletions manifests/ca.pp
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@
}

# Since Debian/Suse based OSes don't have explicit distrust directories
# Logic is Similar for Debian/SLES11 - but breaking into if/elsif
# Logic is Similar for Debian/SLES10/SLES11 - but breaking into if/elsif
# for clarity's sake as we need to change untrusted to absent and warn in the log
if $::osfamily == 'Debian' and $ensure == 'distrusted' {
warning("Cannot explicitly set CA distrust on ${::operatingsystem}.")
warning("Ensuring that ${name} CA is absent from the trusted list.")
$adjusted_ensure = 'absent'
}
elsif ($::osfamily == 'Suse' and $::operatingsystemmajrelease == '11') and $ensure == 'distrusted' {
elsif ($::osfamily == 'Suse' and $::operatingsystemmajrelease =~ /(10|11)/) and $ensure == 'distrusted' {
warning("Cannot explicitly set CA distrust on ${::operatingsystem} ${::operatingsystemmajrelease}.")
warning("Ensuring that ${name} CA is absent from the trusted list.")
$adjusted_ensure = 'absent'
Expand All @@ -61,19 +61,11 @@
$adjusted_ensure = $ensure
}
# Determine Full Resource Name
# Sles 11 Only Supports .pem files
# Sles 10/11 Only Supports .pem files
# Other supported OS variants default to .crt
if $::osfamily == 'Suse' and $::operatingsystemmajrelease == '11' {
if ($::osfamily == 'Suse') and ($::operatingsystemmajrelease =~ /(10|11)/) {
if $source != 'text' and $source !~ /^.*\.pem$/ {
fail("${source} not proper format - SLES 11 CA Files must be in .pem format")
}
}

# Sles 11 Only Supports .pem files
# Other supported OS variants default to .crt
if $::osfamily == 'Suse' and $::operatingsystemmajrelease == '11' {
if $source != 'text' and $source !~ /^.*\.pem$/ {
fail("${source} not proper format - SLES 11 CA Files must be in .pem format")
fail("${source} not proper format - SLES 10/11 CA Files must be in .pem format")
}
}

Expand Down
2 changes: 1 addition & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
$package_name = 'ca-certificates'
}
'Suse': {
if $::operatingsystemmajrelease == '11' {
if $::operatingsystemmajrelease =~ /(10|11)/ {
$trusted_cert_dir = '/etc/ssl/certs'
$update_cmd = 'c_rehash'
$ca_file_extension = 'pem'
Expand Down
1 change: 1 addition & 0 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
{
"operatingsystem": "Suse",
"operatingsystemrelease": [
"10.0",
"11.0",
"12.0"
]
Expand Down
79 changes: 24 additions & 55 deletions spec/classes/ca_cert_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,76 +75,45 @@
}
end
end
context "on a Suse 11 based OS" do
let :facts do
{
:osfamily => 'Suse',
:operatingsystemmajrelease => '11',
}
end

it_behaves_like 'compiles and includes params class' do
end
it { is_expected.to contain_package('openssl-certs') }

it { is_expected.to contain_file("trusted_certs").with(
'ensure' => 'directory',
'path' => '/etc/ssl/certs',
'group' => 'root',
'purge' => 'false',
)
}

context "with purge_unmanaged_CAs set to true" do
let :params do
['10','11'].each do |osmajrel|
context "on a Suse #{osmajrel} based OS" do
let :facts do
{
:purge_unmanaged_CAs => 'true',
:osfamily => 'Suse',
:operatingsystemmajrelease => "#{osmajrel}",
}
end

it_behaves_like 'compiles and includes params class' do
end
it { is_expected.to contain_package('openssl-certs') }

it { is_expected.to contain_file("trusted_certs").with(
'ensure' => 'directory',
'path' => '/etc/ssl/certs',
'group' => 'root',
'purge' => 'true',
'purge' => 'false',
)
}
end
end
context "on a Suse 11 based OS" do
let :facts do
{
:osfamily => 'Suse',
:operatingsystemmajrelease => '11',
}
end

it_behaves_like 'compiles and includes params class' do
end
it { is_expected.to contain_package('openssl-certs') }

it { is_expected.to contain_file("trusted_certs").with(
'ensure' => 'directory',
'path' => '/etc/ssl/certs',
'group' => 'root',
'purge' => 'false',
)
}

context "with purge_unmanaged_CAs set to true" do
let :params do
{
:purge_unmanaged_CAs => 'true',
context "with purge_unmanaged_CAs set to true" do
let :params do
{
:purge_unmanaged_CAs => 'true',
}
end
it { is_expected.to contain_file("trusted_certs").with(
'ensure' => 'directory',
'path' => '/etc/ssl/certs',
'group' => 'root',
'purge' => 'true',
)
}
end
it { is_expected.to contain_file("trusted_certs").with(
'ensure' => 'directory',
'path' => '/etc/ssl/certs',
'group' => 'root',
'purge' => 'true',
)
}
end
end

context "on a Suse 12 based OS" do
let :facts do
{
Expand Down
26 changes: 15 additions & 11 deletions spec/classes/params_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,24 @@
end
end
end
context "On a Suse 12 Operating System" do
let :facts do
{
:osfamily => 'Suse',
:operatingsystemmajrelease => '12',
}
end

it_behaves_like 'compiles and includes params class' do
end
it "should not contain any resources" do
should have_resource_count(0)
['10','11','12'].each do |osmajrel|
context "On a Suse #{osmajrel} Operating System" do
let :facts do
{
:osfamily => 'Suse',
:operatingsystemmajrelease => "#{osmajrel}",
}
end

it_behaves_like 'compiles and includes params class' do
end
it "should not contain any resources" do
should have_resource_count(0)
end
end
end

context "on an unsupported operating system" do
let :facts do
{
Expand Down
30 changes: 16 additions & 14 deletions spec/classes/update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,24 @@
)}

end
context "on a Suse 11 based OS" do
let :facts do
{
:osfamily => 'Suse',
:operatingsystemmajrelease => '11',
}
end
['10','11'].each do |osmajrel|
context "on a Suse #{osmajrel} based OS" do
let :facts do
{
:osfamily => 'Suse',
:operatingsystemmajrelease => "#{osmajrel}",
}
end

it_behaves_like 'compiles and includes params class' do
end
it { is_expected.not_to contain_exec('enable_ca_trust') }
it { is_expected.to contain_exec('ca_cert_update').with(
:command => 'c_rehash',
:refreshonly => true,
)}
it_behaves_like 'compiles and includes params class' do
end
it { is_expected.not_to contain_exec('enable_ca_trust') }
it { is_expected.to contain_exec('ca_cert_update').with(
:command => 'c_rehash',
:refreshonly => true,
)}

end
end
context "on a Suse 12 based OS" do
let :facts do
Expand Down