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

Initial sol-11 support #17

Open
wants to merge 3 commits 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
41 changes: 34 additions & 7 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,39 @@
validate_re($vas_nss_module, '^vas(3|4)$',
'Valid values for vas_nss_module are \'vas3\' and \'vas4\'.')

file { 'nsswitch_config_file':
ensure => file,
path => $config_file,
content => template('nsswitch/nsswitch.conf.erb'),
owner => 'root',
group => 'root',
mode => '0644',
if $::operatingsystem == 'Solaris' and $::operatingsystemrelease =~ /^5\.11/ {

file { '/etc/svccfg.d' :
ensure => directory,
owner => 'root',
group => 'root',
mode => '0755',
before => File[ 'nsswitch_config_file' ],
}
file { 'nsswitch_config_file':
ensure => file,
path => $config_file,
content => template('nsswitch/nsswitch.svccfg.erb'),
owner => 'root',
group => 'root',
mode => '0755',
notify => Exec[ 'nsswitch_svccfg' ],
}
exec { 'nsswitch_svccfg' :
command => $config_file,
path => '/usr/bin:/bin:/usr/sbin:/sbin',
refreshonly => true,
}

} else {

file { 'nsswitch_config_file':
ensure => file,
path => $config_file,
content => template('nsswitch/nsswitch.conf.erb'),
owner => 'root',
group => 'root',
mode => '0644',
}
}
}
24 changes: 23 additions & 1 deletion spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
describe 'nsswitch' do

describe 'included class' do
context 'with defaults' do
context 'with defaults on a supported OS other than Solaris 11' do
let(:facts) { { :operatingsystem => 'Linux' } }
it {
should include_class('nsswitch')
should contain_file('nsswitch_config_file').with({
Expand Down Expand Up @@ -40,6 +41,27 @@
}
end

context 'with defaults on a supported Solaris 11' do
let :params do
{ :config_file => '/etc/svccfg.d/nsswitch' }
end

let :facts do
{ :operatingsystem => 'Solaris', :operatingsystemrelease => '11.0' }
end

it {
should include_class('nsswitch')
should contain_file('nsswitch_config_file').with({
'ensure' => 'file',
'path' => '/etc/svccfg.d/nsswitch',
'owner' => 'root',
'group' => 'root',
'mode' => '0755',
})
}
end

context 'with ldap enabled' do
let :params do
{ :ensure_ldap => 'present' }
Expand Down
26 changes: 26 additions & 0 deletions templates/nsswitch.svccfg.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh
# This file is being maintained by Puppet.
# DO NOT EDIT

svccfg -s name-service/switch setprop config/passwd = astring: '(" files<% if @ensure_ldap == 'present' %> ldap<% end %><% if @ensure_vas == 'present' %> <%= vas_nss_module %><% end %>")'
svccfg -s name-service/switch setprop config/shadow = astring: '(" files<% if @ensure_ldap == 'present' %> ldap<% end %>")'
svccfg -s name-service/switch setprop config/group = astring: '(" files<% if @ensure_ldap == 'present' %> ldap<% end %><% if @ensure_vas == 'present' %> <%= vas_nss_module %><% end %>")'

svccfg -s name-service/switch setprop config/sudoers = astring: '(" files<% if @ensure_ldap == 'present' %> ldap<% end %>")'

svccfg -s name-service/switch setprop config/hosts = astring: '(" files dns")'

svccfg -s name-service/switch setprop config/bootparams = astring: '(" files")'
svccfg -s name-service/switch setprop config/ethers = astring: '(" files")'
svccfg -s name-service/switch setprop config/netmasks = astring: '(" files")'
svccfg -s name-service/switch setprop config/networks = astring: '(" files")'
svccfg -s name-service/switch setprop config/protocols = astring: '(" files<% if @ensure_ldap == 'present' %> ldap<% end %>")'
svccfg -s name-service/switch setprop config/rpc = astring: '(" files")'
svccfg -s name-service/switch setprop config/services = astring: '(" files<% if @ensure_ldap == 'present' %> ldap<% end %>")'
svccfg -s name-service/switch setprop config/netgroup = astring: '(" files<% if @ensure_ldap == 'present' %> ldap<% end %><% if @ensure_vas == 'present' %> nis<% end %>")'
svccfg -s name-service/switch setprop config/publickey = astring: '(" files")'
svccfg -s name-service/switch setprop config/automount = astring: '(" files<% if @ensure_ldap == 'present' %> ldap<% end %><% if @ensure_vas == 'present' %> nis<% end %>")'
svccfg -s name-service/switch setprop config/aliases = astring: '(" files")'

svcadm refresh name-service/switch

4 changes: 4 additions & 0 deletions tests/sol11.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class { 'nsswitch' :
config_file => '/etc/svccfg.d/nsswitch',
}