-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
Add parameters for configuring package and service #31
Changes from 23 commits
7634c24
9cc8e25
9265d28
ad31fb8
344899c
f8749fc
2308621
bb7a462
c6f9396
c620d5d
b7bef68
2e56a06
20d1951
4567a53
3490e69
9bbab1b
c32427a
60396db
278bd58
0b63021
18dca69
4821c03
473ff62
e7fc98f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,9 +12,24 @@ | |
# @author Vox Pupuli <[email protected]> | ||
# @author David Hollinger III <[email protected]> | ||
# | ||
# To use this module, simply declare it in your manifest. | ||
# @example Declaring the autofs class | ||
# include autofs | ||
# | ||
# The module now supports the ability to not only enable autofs, | ||
# but to also disable or uninstall it completely. | ||
# @example Removing the package | ||
# class { 'autofs': | ||
# package_ensure => 'absent', | ||
# } | ||
# | ||
# @example Disable the autofs service | ||
# class { 'autofs': | ||
# service_ensure => 'stopped', | ||
# service_enable => false, | ||
# } | ||
# | ||
# | ||
# @example using hiera with automatic lookup | ||
# --- | ||
# autofs::mounts: | ||
|
@@ -44,12 +59,22 @@ | |
# @option mounts [Array] :mapcontents Mount point options and parameters. Each | ||
# array element represents a line in the configuration file. | ||
# @option mounts [Boolean] :replace Enforce the configuration state or not. | ||
# @param package_ensure Determines the state of the package. Can be set to: installed, absent, lastest, or a specific version string. | ||
# @param service_ensure Determines state of the service. Can be set to: running or stopped. | ||
# @param service_enable Determines if the service should start with the system boot. true | ||
# will start the autofs service on boot. false will not start the autofs service | ||
# on boot. | ||
# | ||
class autofs ( | ||
Optional[Hash] $mounts = undef | ||
Optional[Hash] $mounts = undef, | ||
String $package_ensure = 'installed', | ||
Enum[ 'stopped', 'running' ] $service_ensure = 'running', | ||
Boolean $service_enable = true, | ||
) { | ||
contain '::autofs::package' | ||
contain '::autofs::service' | ||
unless $package_ensure == 'absent' { | ||
contain '::autofs::service' | ||
} | ||
|
||
if $mounts { | ||
$data = hiera_hash('autofs::mounts', $mounts) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,26 +13,12 @@ | |
# @author Vox Pupuli <[email protected]> | ||
# @author David Hollinger III <[email protected]> | ||
# | ||
# @param ensure Determines state of the service. Can be set to: running or stopped. | ||
# @param enable Determines if the service should start with the system boot. true | ||
# will start the autofs service on boot. false will not start the autofs service | ||
# on boot. | ||
# @param service_restart Determines if the service has a restart command. If true, | ||
# puppet will use the restart command to restart the service. If false, the | ||
# stop, then start commands will be used instead. | ||
# @param service_status Determines if service has a status command. | ||
# | ||
class autofs::service ( | ||
String $ensure = running, | ||
Boolean $enable = true, | ||
Boolean $service_restart = true, | ||
Boolean $service_status = true | ||
){ | ||
class autofs::service { | ||
service { 'autofs': | ||
ensure => $ensure, | ||
enable => $enable, | ||
hasstatus => $service_status, | ||
hasrestart => $service_restart, | ||
ensure => $autofs::service_ensure, | ||
enable => $autofs::service_enable, | ||
hasstatus => true, | ||
hasrestart => true, | ||
require => Package['autofs'], | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,30 +4,40 @@ | |
describe 'autofs', type: :class do | ||
let(:hiera_config) { 'spec/fixtures/hiera/hiera.yaml' } | ||
hiera = Hiera.new(config: 'spec/fixtures/hiera/hiera.yaml') | ||
opsys = %w( | ||
Debian | ||
Ubuntu | ||
RedHat | ||
CentOS | ||
Suse | ||
) | ||
|
||
opsys.each do |os| | ||
context 'main init tests' do | ||
on_supported_os.select { |_, f| f[:os]['family'] != 'Solaris' }.each do |os, facts| | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. _, f |
||
context "on #{os}" do | ||
let :facts do | ||
facts | ||
end | ||
|
||
context 'main init tests' do | ||
let(:facts) do | ||
facts.merge(concat_basedir: '/etc') | ||
end | ||
it { is_expected.to compile } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we do compile.with_all_deps? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. eep, sorry @bastelfreak, saw that it was approved and @dhollinger had asked for a merge earlier in the day; didn't see that these comments were so recent. |
||
it { is_expected.to contain_class('autofs') } | ||
it { is_expected.to contain_class('autofs::package') } | ||
it { is_expected.to contain_class('autofs::service') } | ||
|
||
# Check Package and service | ||
it { is_expected.to contain_package('autofs').with_ensure('installed') } | ||
it { is_expected.to contain_service('autofs').that_requires('Package[autofs]') } | ||
it { is_expected.to contain_service('autofs').with_ensure('running') } | ||
it { is_expected.to contain_service('autofs').with_enable(true) } | ||
end | ||
end | ||
|
||
context 'disable package' do | ||
let(:facts) do | ||
facts.merge(concat_basedir: '/etc') | ||
end | ||
let(:params) do | ||
{ | ||
osfamily: os.to_s, | ||
concat_basedir: '/etc' | ||
package_ensure: 'absent' | ||
} | ||
end | ||
it { is_expected.to compile } | ||
it { is_expected.to contain_class('autofs') } | ||
it { is_expected.to contain_class('autofs::package') } | ||
it { is_expected.to contain_class('autofs::service') } | ||
|
||
# Check Package and service | ||
it { is_expected.to contain_package('autofs').with_ensure('installed') } | ||
it { is_expected.to contain_service('autofs').that_requires('Package[autofs]') } | ||
it { is_expected.to contain_package('autofs').with_ensure('absent') } | ||
end | ||
end | ||
|
||
|
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dhollinger maybe keep the empty Solaris block here then? otherwise the immediate fail() seems somewhat incompatible with self-support
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Nice catch