Skip to content

Commit

Permalink
use ensure_resource for ancillary pkgs/services
Browse files Browse the repository at this point in the history
  • Loading branch information
dannygoulder committed Nov 1, 2016
1 parent ad108f6 commit 8560cd4
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
fixtures:
repositories:
'stdlib':
repo: "git://github.com/puppetlabs/puppetlabs-stdlib"
repo: "https://github.com/puppetlabs/puppetlabs-stdlib"
symlinks:
authconfig: "#{source_dir}"
9 changes: 8 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ group :development, :unit_tests do
end

group :system_tests do
gem 'beaker-rspec', :require => false
gem 'serverspec', :require => false
end

Expand All @@ -39,4 +38,12 @@ else
gem 'puppet', :require => false
end

if RUBY_VERSION < '2.2.5'
# beaker 3.1+ requires ruby 2.2.5. Lock to 2.0
gem 'beaker', '~> 2.0', :require => false
# beaker-rspec 6.0.0 requires beaker 3.0. Lock to 5.6.0
gem 'beaker-rspec', '= 5.6.0', :require => false
end


# vim:ft=ruby
46 changes: 25 additions & 21 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@
# [*mkhomedir*]
#
# [*smartc*]
# Boolean to enable or disable SmartCard Authentication.
# Boolean to enable or disable SmartCard Authentication.
# (Default: false)
#
# [*smartcaction*]
# Boolean to determine SmartCard Removal Action. Values: True = Lock, False = Ignore
# Boolean to determine SmartCard Removal Action. Values: True = Lock, False = Ignore
# (Default: false)
#
# [*smartcrequire*]
Expand Down Expand Up @@ -489,63 +489,67 @@
$exec_check_cmd = "/usr/bin/test \"`${authconfig_test_cmd}`\" = \"`authconfig --test`\""

if $cache {
package { $authconfig::params::cache_packages:
ensure_resource('package', $authconfig::params::cache_packages, {
ensure => installed,
} ->
service { $authconfig::params::cache_services:
ensure => running,
})
ensure_resource('service', $authconfig::params::cache_services, {
ensure => running,
enable => true,
hasstatus => true,
hasrestart => true,
}
})
Package[$authconfig::params::cache_packages] ->
Service[$authconfig::params::cache_services]
}

if $krb5 {
package { $authconfig::params::krb5_packages:
ensure_resource('package', $authconfig::params::krb5_packages, {
ensure => installed,
}
})
}

if $sssd {
# if we're using sssd, then sssd takes care of ldap connectivity.
# therefore, we only need the sssd packages and services, not the
# ldap packages and services
package { $authconfig::params::sssd_packages:
ensure_resource('package', $authconfig::params::sssd_packages, {
ensure => installed,
}
})
# sssd services must only run after the authconfig command has set
# up the config.
service { $authconfig::params::sssd_services:
ensure_resource('service', $authconfig::params::sssd_services, {
ensure => running,
enable => true,
hasstatus => true,
hasrestart => true,
require => Exec['authconfig command'],
}
})
} elsif $ldap {
package { $authconfig::params::ldap_packages:
ensure_resource('package', $authconfig::params::ldap_packages, {
ensure => installed,
} ->
service { $authconfig::params::ldap_services:
})
ensure_resource('service', $authconfig::params::ldap_services, {
ensure => running,
enable => true,
hasstatus => true,
hasrestart => true,
before => Exec['authconfig command'],
}
})
Package[$authconfig::params::ldap_packages] ->
Service[$authconfig::params::ldap_services]
}

if $mkhomedir {
package { $authconfig::params::mkhomedir_packages:
ensure_resource('package', $authconfig::params::mkhomedir_packages, {
ensure => installed,
}
})
# service oddjobd is started automatically by authconfig
}

if $smartc {
package { $authconfig::params::smartcard_packages:
ensure_resource('package', $authconfig::params::smartcard_packages, {
ensure => installed,
}
})
}

package { $authconfig::params::packages:
Expand Down
23 changes: 23 additions & 0 deletions spec/classes/authconfig_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,29 @@

end

context 'SSSD enabled' do
before :each do
params.merge!(
:sssd => true,
)
end

['sssd','sssd-client'].each do |package|
it "installs package: #{package}" do
should contain_package(package)
end
end

it 'configures service: sssd' do
should contain_service('sssd').with({
'ensure' => 'running',
'enable' => 'true',
'hasstatus' => 'true',
'hasrestart' => 'true',
})
end

end

end

Expand Down

1 comment on commit 8560cd4

@dannygoulder
Copy link
Author

@dannygoulder dannygoulder commented on 8560cd4 Mar 21, 2017

Choose a reason for hiding this comment

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

This is to allow other modules to declare the ancillary packages and services (as they should contain their own resources). e.g. for sgnl05/sssd

Please sign in to comment.