Permalink
Browse files

Add pam to augeasproviders::instances

  • Loading branch information...
1 parent 5809513 commit b1cbf417cc70a8d329a54b618c8b4f41000e66f0 Dominic Cleal committed May 5, 2014
Showing with 54 additions and 1 deletion.
  1. +6 −0 manifests/instances.pp
  2. +7 −1 manifests/params.pp
  3. +1 −0 spec/classes/augeasproviders_instances_spec.rb
  4. +40 −0 spec/support/pam.rb
View
@@ -9,6 +9,7 @@
$mailalias_hash = $augeasproviders::params::mailalias_hash,
$mounttab_hash = $augeasproviders::params::mounttab_hash,
$nrpe_command_hash = $augeasproviders::params::nrpe_command_hash,
+ $pam_hash = $augeasproviders::params::pam_hash,
$pg_hba_hash = $augeasproviders::params::pg_hba_hash,
$puppet_auth_hash = $augeasproviders::params::puppet_auth_hash,
$shellvar_hash = $augeasproviders::params::shellvar_hash,
@@ -56,6 +57,11 @@
create_resources(nrpe_command, $nrpe_command_hash, $resource_defaults['nrpe_command'])
}
+ if $pam_hash and !empty($pam_hash) {
+ validate_hash($pam_hash)
+ create_resources(pam, $pam_hash, $resource_defaults['pam'])
+ }
+
if $pg_hba_hash and !empty($pg_hba_hash) {
validate_hash($pg_hba_hash)
create_resources(pg_hba, $pg_hba_hash, $resource_defaults['pg_hba'])
View
@@ -39,6 +39,11 @@
default => $::augeasproviders_nrpe_command_hash,
}
+ $pam_hash = $::augeasproviders_pam_hash ? {
+ undef => false,
+ default => $::augeasproviders_pam_hash,
+ }
+
$pg_hba_hash = $::augeasproviders_pg_hba_hash ? {
undef => false,
default => $::augeasproviders_pg_hba_hash,
@@ -87,6 +92,7 @@
'mailalias' => $defaults,
'mounttab' => $defaults,
'nrpe_command' => $defaults,
+ 'pam' => $defaults,
'pg_hba' => $defaults,
'puppet_auth' => $defaults,
'shellvar' => $defaults,
@@ -96,4 +102,4 @@
'syslog' => $defaults,
}
-}
+}
@@ -17,6 +17,7 @@
'mailalias',
'mounttab',
'nrpe_command',
+ 'pam',
'pg_hba',
'puppet_auth',
'shellvar',
View
@@ -0,0 +1,40 @@
+shared_examples_for 'pam resource' do
+ it { should have_pam_resource_count(1) }
+
+ it do
+ should contain_pam('Add pam_test.so to auth for system-auth').only_with({
+ 'name' => 'Add pam_test.so to auth for system-auth',
+ 'service' => 'system-auth',
+ 'type' => 'auth',
+ 'control' => 'sufficient',
+ 'module' => 'pam_test.so',
+ 'arguments' => 'test_me_out',
+ 'position' => 'before module pam_deny.so',
+ 'target' => '/etc/pam.d/system-auth',
+ 'provider' => 'augeas',
+ 'ensure' => 'present',
+ })
+ end
+end
+
+shared_context 'pam' do
+ it { should have_pam_resource_count(0) }
+
+ let :example_params do
+ { 'Add pam_test.so to auth for system-auth' => {'service' => 'system-auth', 'type' => 'auth', 'control' => 'sufficient', 'module' => 'pam_test.so', 'arguments' => 'test_me_out', 'position' => 'before module pam_deny.so', 'target' => '/etc/pam.d/system-auth', 'provider' => 'augeas', 'ensure' => 'present'}}
+ end
+
+ context "when pam_hash is a Hash" do
+ let(:params) {{ :pam_hash => example_params }}
+ let(:facts) {{}}
+
+ include_examples 'pam resource'
+ end
+
+ context "when ::augeasproviders_pam_hash is a Hash" do
+ let(:params) {{}}
+ let(:facts) {{ :augeasproviders_pam_hash => example_params }}
+
+ include_examples 'pam resource'
+ end
+end

0 comments on commit b1cbf41

Please sign in to comment.