Skip to content

Add service_ensure option to allow control of services running or not #6

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

Merged
merged 2 commits into from
Oct 26, 2015
Merged
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
9 changes: 8 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@
# Boolean. Manage auto-creation of home directories on user login.
#
# [*enable_mkhomedir_flags*]
# Flags to use with authconfig to enable auto-creation of home directories.
# Flags to use with authconfig to enable auto-creation of home directories.
#
# [*disable_mkhomedir_flags*]
# Flags to use with authconfig to disable auto-creation of home directories.
#
# [*service_ensure*]
# Ensure if services should be running/stopped
#
# === Examples
#
# class {'::sssd':
Expand Down Expand Up @@ -66,10 +69,12 @@
$config = $sssd::params::config,
$sssd_package = $sssd::params::sssd_package,
$sssd_service = $sssd::params::sssd_service,
$sssd_ensure = $sssd::params::sssd_ensure,
$extra_packages = $sssd::params::extra_packages,
$config_file = $sssd::params::config_file,
$mkhomedir = $sssd::params::mkhomedir,
$manage_oddjobd = $sssd::params::manage_oddjobd,
$service_ensure = $sssd::params::service_ensure,
$enable_mkhomedir_flags = $sssd::params::enable_mkhomedir_flags,
$disable_mkhomedir_flags = $sssd::params::disable_mkhomedir_flags,
) inherits sssd::params {
Expand Down Expand Up @@ -101,6 +106,8 @@
$config
)

validate_re($service_ensure, '^running|true|stopped|false$')

anchor { 'sssd::begin': } ->
class { '::sssd::install': } ->
class { '::sssd::config': } ~>
Expand Down
10 changes: 6 additions & 4 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@

'RedHat': {

$sssd_package = 'sssd'
$sssd_service = 'sssd'
$config_file = '/etc/sssd/sssd.conf'
$mkhomedir = true
$sssd_package = 'sssd'
$sssd_service = 'sssd'
$service_ensure = 'running'
$config_file = '/etc/sssd/sssd.conf'
$mkhomedir = true

if versioncmp($::operatingsystemrelease, '6.0') < 0 {
$extra_packages = [
Expand All @@ -45,6 +46,7 @@

$sssd_package = 'sssd'
$sssd_service = 'sssd'
$service_ensure = 'running'
$config_file = '/etc/sssd/sssd.conf'
$mkhomedir = true
$extra_packages = [
Expand Down
6 changes: 3 additions & 3 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
$sssd_service = $sssd::sssd_service,
$mkhomedir = $sssd::mkhomedir,
$manage_oddjobd = $sssd::manage_oddjobd,
$service_ensure = $sssd::service_ensure,
) {

service { $sssd_service:
ensure => running,
ensure => $service_ensure,
enable => true,
hasstatus => true,
hasrestart => true,
Expand All @@ -15,7 +15,7 @@
if $mkhomedir and $manage_oddjobd {

service { 'oddjobd':
ensure => running,
ensure => $service_ensure,
enable => true,
hasstatus => true,
hasrestart => true,
Expand Down
32 changes: 32 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@

it { is_expected.not_to contain_package('oddjob-mkhomedir') }
it { is_expected.not_to contain_service('oddjobd') }

it { is_expected.to contain_service('sssd').with_ensure('running') }
end

context 'with service ensure stopped' do
let (:params) { { :service_ensure => 'stopped' } }
it { is_expected.to contain_service('sssd').with_ensure('stopped') }
end
end
describe "on RedHat 6.6" do
Expand All @@ -22,6 +29,15 @@

it { is_expected.to contain_package('oddjob-mkhomedir') }
it { is_expected.to contain_service('oddjobd') }

it { is_expected.to contain_service('sssd').with_ensure('running') }
it { is_expected.to contain_service('oddjobd').with_ensure('running') }
end

context 'with service ensure stopped' do
let (:params) { { :service_ensure => 'stopped' } }
it { is_expected.to contain_service('sssd').with_ensure('stopped') }
it { is_expected.to contain_service('oddjobd').with_ensure('stopped') }
end
end
describe "on RedHat 7.1" do
Expand All @@ -34,6 +50,15 @@

it { is_expected.to contain_package('oddjob-mkhomedir') }
it { is_expected.to contain_service('oddjobd') }

it { is_expected.to contain_service('sssd').with_ensure('running') }
it { is_expected.to contain_service('oddjobd').with_ensure('running') }
end

context 'with service ensure stopped' do
let (:params) { { :service_ensure => 'stopped' } }
it { is_expected.to contain_service('sssd').with_ensure('stopped') }
it { is_expected.to contain_service('oddjobd').with_ensure('stopped') }
end
end
describe "on Debian 8.1" do
Expand All @@ -46,6 +71,13 @@

it { is_expected.not_to contain_package('oddjob-mkhomedir') }
it { is_expected.not_to contain_service('oddjobd') }

it { is_expected.to contain_service('sssd').with_ensure('running') }
end

context 'with service ensure stopped' do
let (:params) { { :service_ensure => 'stopped' } }
it { is_expected.to contain_service('sssd').with_ensure('stopped') }
end
end
end