From 49747a1cfbcf892eab0cbeb24258b0b306368e6e Mon Sep 17 00:00:00 2001 From: Nils Olof Paulsson Date: Thu, 22 Aug 2013 16:13:59 +0200 Subject: [PATCH 1/3] Initial sol-11 support --- manifests/init.pp | 41 +++++++++++++++++++++++++++++------ templates/nsswitch.svccfg.erb | 26 ++++++++++++++++++++++ 2 files changed, 60 insertions(+), 7 deletions(-) create mode 100644 templates/nsswitch.svccfg.erb diff --git a/manifests/init.pp b/manifests/init.pp index ddf3bbd..a189a8b 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 =~ /^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 => "/etc/svccfg.d/${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/templates/nsswitch.svccfg.erb b/templates/nsswitch.svccfg.erb new file mode 100644 index 0000000..31ddd13 --- /dev/null +++ b/templates/nsswitch.svccfg.erb @@ -0,0 +1,26 @@ +#!/bin/sh +# This file is being maintained by Puppet. +# DO NOT EDIT + +svccfgg -s name-service/switch setprop config/passwd = astring: '(" files<% if @ensure_ldap == 'present' %> ldap<% end %><% if @ensure_vas == 'present' %> <%= vas_nss_module %><% end %>")' +svccfgg -s name-service/switch setprop config/shadow = astring: '(" files<% if @ensure_ldap == 'present' %> ldap<% end %>")' +svccfgg -s name-service/switch setprop config/group = astring: '(" files<% if @ensure_ldap == 'present' %> ldap<% end %><% if @ensure_vas == 'present' %> <%= vas_nss_module %><% end %>")' + +svccfgg -s name-service/switch setprop config/sudoers = astring: '(" files<% if @ensure_ldap == 'present' %> ldap<% end %>")' + +svccfgg -s name-service/switch setprop config/hosts = astring: '(" files dns")' + +svccfgg -s name-service/switch setprop config/bootparams = astring: '(" files")' +svccfgg -s name-service/switch setprop config/ethers = astring: '(" files")' +svccfgg -s name-service/switch setprop config/netmasks = astring: '(" files")' +svccfgg -s name-service/switch setprop config/networks = astring: '(" files")' +svccfgg -s name-service/switch setprop config/protocols = astring: '(" files<% if @ensure_ldap == 'present' %> ldap<% end %>")' +svccfgg -s name-service/switch setprop config/rpc = astring: '(" files")' +svccfgg -s name-service/switch setprop config/services = astring: '(" files<% if @ensure_ldap == 'present' %> ldap<% end %>")' +svccfgg -s name-service/switch setprop config/netgroup = astring: '(" files<% if @ensure_ldap == 'present' %> ldap<% end %><% if @ensure_vas == 'present' %> nis<% end %>")' +svccfgg -s name-service/switch setprop config/publickey = astring: '(" files")' +svccfgg -s name-service/switch setprop config/automount = astring: '(" files<% if @ensure_ldap == 'present' %> ldap<% end %><% if @ensure_vas == 'present' %> nis<% end %>")' +svccfgg -s name-service/switch setprop config/aliases = astring: '(" files")' + +svcadm refresh name-service/switch + From 09091c5ab082af7b763489387c77e4642f83975d Mon Sep 17 00:00:00 2001 From: Nils Olof Paulsson Date: Thu, 22 Aug 2013 23:59:52 +0200 Subject: [PATCH 2/3] Fix path bug. Add sol-11 rspec test. --- manifests/init.pp | 4 ++-- spec/classes/init_spec.rb | 24 +++++++++++++++++++++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index a189a8b..9e8fed5 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -35,8 +35,8 @@ mode => '0755', notify => Exec[ 'nsswitch_svccfg' ], } - Exec { 'nsswitch_svccfg' : - command => "/etc/svccfg.d/${config_file}", + exec { 'nsswitch_svccfg' : + command => $config_file, path => '/usr/bin:/bin:/usr/sbin:/sbin', refreshonly => true, } 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' } From 0b6d471e4f52c1543a507060becce17b02e743fe Mon Sep 17 00:00:00 2001 From: Nils Olof Paulsson Date: Fri, 23 Aug 2013 14:17:17 +0200 Subject: [PATCH 3/3] Fix test manifest. Fix bugs. Fix template bug --- manifests/init.pp | 2 +- templates/nsswitch.svccfg.erb | 32 ++++++++++++++++---------------- tests/sol11.pp | 4 ++++ 3 files changed, 21 insertions(+), 17 deletions(-) create mode 100644 tests/sol11.pp diff --git a/manifests/init.pp b/manifests/init.pp index 9e8fed5..07abc74 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -17,7 +17,7 @@ validate_re($vas_nss_module, '^vas(3|4)$', 'Valid values for vas_nss_module are \'vas3\' and \'vas4\'.') - if $::operatingsystem == 'Solaris' and $::operatingsystemrelease =~ /^11/ { + if $::operatingsystem == 'Solaris' and $::operatingsystemrelease =~ /^5\.11/ { file { '/etc/svccfg.d' : ensure => directory, diff --git a/templates/nsswitch.svccfg.erb b/templates/nsswitch.svccfg.erb index 31ddd13..a7912b2 100644 --- a/templates/nsswitch.svccfg.erb +++ b/templates/nsswitch.svccfg.erb @@ -2,25 +2,25 @@ # This file is being maintained by Puppet. # DO NOT EDIT -svccfgg -s name-service/switch setprop config/passwd = astring: '(" files<% if @ensure_ldap == 'present' %> ldap<% end %><% if @ensure_vas == 'present' %> <%= vas_nss_module %><% end %>")' -svccfgg -s name-service/switch setprop config/shadow = astring: '(" files<% if @ensure_ldap == 'present' %> ldap<% end %>")' -svccfgg -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/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 %>")' -svccfgg -s name-service/switch setprop config/sudoers = astring: '(" files<% if @ensure_ldap == 'present' %> ldap<% end %>")' +svccfg -s name-service/switch setprop config/sudoers = astring: '(" files<% if @ensure_ldap == 'present' %> ldap<% end %>")' -svccfgg -s name-service/switch setprop config/hosts = astring: '(" files dns")' +svccfg -s name-service/switch setprop config/hosts = astring: '(" files dns")' -svccfgg -s name-service/switch setprop config/bootparams = astring: '(" files")' -svccfgg -s name-service/switch setprop config/ethers = astring: '(" files")' -svccfgg -s name-service/switch setprop config/netmasks = astring: '(" files")' -svccfgg -s name-service/switch setprop config/networks = astring: '(" files")' -svccfgg -s name-service/switch setprop config/protocols = astring: '(" files<% if @ensure_ldap == 'present' %> ldap<% end %>")' -svccfgg -s name-service/switch setprop config/rpc = astring: '(" files")' -svccfgg -s name-service/switch setprop config/services = astring: '(" files<% if @ensure_ldap == 'present' %> ldap<% end %>")' -svccfgg -s name-service/switch setprop config/netgroup = astring: '(" files<% if @ensure_ldap == 'present' %> ldap<% end %><% if @ensure_vas == 'present' %> nis<% end %>")' -svccfgg -s name-service/switch setprop config/publickey = astring: '(" files")' -svccfgg -s name-service/switch setprop config/automount = astring: '(" files<% if @ensure_ldap == 'present' %> ldap<% end %><% if @ensure_vas == 'present' %> nis<% end %>")' -svccfgg -s name-service/switch setprop config/aliases = astring: '(" files")' +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', +} +