Skip to content

Add support for OpenSuse 13.1 support. #30

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

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
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Puppet v3 with Ruby 1.8.7, 1.9.3, 2.0.0 and 2.1.0.
* EL 7
* Solaris 10
* Suse
* OpenSuSE 13.1

===

Expand Down Expand Up @@ -111,3 +112,15 @@ nsswitch_project
String of list of sources for project database. 'USE_DEFAULTS' allows the module to choose defaults based on the platform.

- *Default*: 'USE_DEFAULTS'

networks
--------
String of list of sources for networks database. 'USE_DEFAULTS' allows the module to choose defaults based on the platform.

- *Default*: 'USE_DEFAULTS'

sudoers
-------
String of list of sources for sudoers database. 'USE_DEFAULTS' allows the module to choose defaults based on the platform.

- *Default*: 'USE_DEFAULTS'
66 changes: 65 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
$vas_nss_module_services = '',
$passwd = 'USE_DEFAULTS',
$shadow = 'USE_DEFAULTS',
$sudoers = 'USE_DEFAULTS',
$group = 'USE_DEFAULTS',
$hosts = 'USE_DEFAULTS',
$networks = 'USE_DEFAULTS',
$automount = 'USE_DEFAULTS',
$services = 'USE_DEFAULTS',
$bootparams = 'USE_DEFAULTS',
Expand All @@ -42,11 +44,13 @@
validate_string($vas_nss_module_services)

case $::osfamily {
'Debian','Suse': {
'Debian': {
$default_passwd = 'files'
$default_shadow = 'files'
$default_sudoers = 'files'
$default_group = 'files'
$default_hosts = 'files dns'
$default_networks = 'files'
$default_automount = 'files'
$default_services = 'files'
$default_bootparams = 'files'
Expand All @@ -58,12 +62,54 @@
$default_nsswitch_auth_attr = undef
$default_nsswitch_prof_attr = undef
}
'Suse': {
case $::lsbmajdistrelease {
'13': {
$default_passwd = 'compat'
$default_shadow = undef
$default_sudoers = undef
$default_group = 'compat'
$default_hosts = 'files mdns_minimal [NOTFOUND=return] dns'
$default_networks = 'files dns'
$default_automount = 'files nis'
$default_services = 'files'
$default_bootparams = 'files'
$default_aliases = 'files'
$default_publickey = 'files'
$default_netgroup = 'files nis'
$default_nsswitch_ipnodes = undef
$default_nsswitch_printers = undef
$default_nsswitch_auth_attr = undef
$default_nsswitch_prof_attr = undef
}
default: {
$default_passwd = 'files'
$default_shadow = 'files'
$default_sudoers = 'files'
$default_group = 'files'
$default_hosts = 'files dns'
$default_networks = 'files'
$default_automount = 'files'
$default_services = 'files'
$default_bootparams = 'files'
$default_aliases = 'files'
$default_publickey = 'files'
$default_netgroup = 'files'
$default_nsswitch_ipnodes = undef
$default_nsswitch_printers = undef
$default_nsswitch_auth_attr = undef
$default_nsswitch_prof_attr = undef
}
}
}
'RedHat': {
if $::operatingsystemmajrelease == '7' {
$default_passwd = 'files sss'
$default_shadow = 'files sss'
$default_sudoers = 'files'
$default_group = 'files sss'
$default_hosts = 'files dns myhostname'
$default_networks = 'files'
$default_automount = 'files sss'
$default_services = 'files sss'
$default_bootparams = 'nisplus [NOTFOUND=return] files'
Expand All @@ -73,8 +119,10 @@
} else {
$default_passwd = 'files'
$default_shadow = 'files'
$default_sudoers = 'files'
$default_group = 'files'
$default_hosts = 'files dns'
$default_networks = 'files'
$default_automount = 'files'
$default_services = 'files'
$default_bootparams = 'files'
Expand All @@ -91,8 +139,10 @@
'Solaris': {
$default_passwd = 'files'
$default_shadow = 'files'
$default_sudoers = 'files'
$default_group = 'files'
$default_hosts = 'files dns'
$default_networks = 'files'
$default_automount = 'files'
$default_services = 'files'
$default_bootparams = 'files'
Expand Down Expand Up @@ -124,6 +174,13 @@
}
validate_string($shadow_real)

if $sudoers == 'USE_DEFAULTS' {
$sudoers_real = $default_sudoers
} else {
$sudoers_real = $sudoers
}
validate_string($sudoers_real)
Copy link
Owner

Choose a reason for hiding this comment

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

needs a test to show that if a non-string is used, that the error occurs


if $group == 'USE_DEFAULTS' {
$group_real = $default_group
} else {
Expand All @@ -138,6 +195,13 @@
}
validate_string($hosts_real)

if $networks == 'USE_DEFAULTS' {
$networks_real = $default_networks
} else {
$networks_real = $networks
}
validate_string($networks_real)
Copy link
Owner

Choose a reason for hiding this comment

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

needs a test to show that if a non-string is used, that the error occurs


if $automount == 'USE_DEFAULTS' {
$automount_real = $default_automount
} else {
Expand Down
6 changes: 6 additions & 0 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@
},
{
"operatingsystem": "SLED"
},
{
"operatingsystem": "OpenSuSE",
"operatingsystemrelease": [
"13.1"
]
}
],
"description": "Manage nsswitch. Supports LDAP integration.",
Expand Down
67 changes: 67 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,51 @@
end
end

context 'on Suse 13' do
let(:facts) do
{ :osfamily => 'Suse',
:lsbmajdistrelease => '13',
}
end

it { should contain_class('nsswitch') }

it {
should contain_file('nsswitch_config_file').with({
'ensure' => 'file',
'path' => '/etc/nsswitch.conf',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
}

it {
should contain_file('nsswitch_config_file').with_content(
%{# This file is being maintained by Puppet.
# DO NOT EDIT

passwd: compat
group: compat


hosts: files mdns_minimal [NOTFOUND=return] dns

bootparams: files
ethers: files
netmasks: files
networks: files dns
protocols: files
rpc: files
services: files
netgroup: files nis
publickey: files
automount: files nis
aliases: files
})
}
end

context 'on RedHat 7' do
let(:facts) do
{ :osfamily => 'RedHat',
Expand Down Expand Up @@ -408,6 +453,28 @@
}
end

context 'networks with invalid type' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) { { :networks => ['not','a','string'] } }

it do
expect {
should contain_class('nsswitch')
}.to raise_error(Puppet::Error,/\["not", "a", "string"\] is not a string/)
end
end

context 'sudoers with invalid type' do
let(:facts) { { :osfamily => 'RedHat' } }
let(:params) { { :sudoers => ['not','a','string'] } }

it do
expect {
should contain_class('nsswitch')
}.to raise_error(Puppet::Error,/\["not", "a", "string"\] is not a string/)
end
end

context 'with config_file set' do
let :params do
{ :config_file => '/path/to/nsswitch.conf' }
Expand Down
8 changes: 6 additions & 2 deletions templates/nsswitch.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@
# DO NOT EDIT

passwd: <%= @passwd_real %><% if @ensure_ldap == 'present' %> ldap<% end %><% if @ensure_vas == 'present' %> <%= @vas_nss_module_passwd %><% end %>
<% if @shadow_real -%>
shadow: <%= @shadow_real %><% if @ensure_ldap == 'present' %> ldap<% end %>
<% end -%>
group: <%= @group_real %><% if @ensure_ldap == 'present' %> ldap<% end %><% if @ensure_vas == 'present' %> <%= @vas_nss_module_group %><% end %>

sudoers: files<% if @ensure_ldap == 'present' %> ldap<% end %>
<% if @sudoers_real -%>
sudoers: <%= @sudoers_real %><% if @ensure_ldap == 'present' %> ldap<% end %>
<% end -%>

hosts: <%= @hosts_real %>

bootparams: <%= @bootparams_real %>
ethers: files
netmasks: files
networks: files
networks: <%= @networks_real %>
protocols: files<% if @ensure_ldap == 'present' %> ldap<% end %>
rpc: files
services: <%= @services_real %><% if @ensure_ldap == 'present' %> ldap<% end %><% if @ensure_vas == 'present' %><% if @vas_nss_module_services != '' %> <%= @vas_nss_module_services %><% end %><% end %>
Expand Down