diff --git a/manifests/init.pp b/manifests/init.pp index ddf3bbd..07abc74 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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', + } } } diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index f0fbdd5..bf7ab30 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -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({ @@ -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' } diff --git a/templates/nsswitch.svccfg.erb b/templates/nsswitch.svccfg.erb new file mode 100644 index 0000000..a7912b2 --- /dev/null +++ b/templates/nsswitch.svccfg.erb @@ -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 + diff --git a/tests/sol11.pp b/tests/sol11.pp new file mode 100644 index 0000000..c2f12b4 --- /dev/null +++ b/tests/sol11.pp @@ -0,0 +1,4 @@ +class { 'nsswitch' : + config_file => '/etc/svccfg.d/nsswitch', +} +