Skip to content

Commit 5486895

Browse files
Merge pull request #46 from gertvdijk/manualrunstyle2
Add the ability to not manage the Puppet agent service
2 parents 6f4489e + 9a7bf4f commit 5486895

File tree

2 files changed

+36
-11
lines changed

2 files changed

+36
-11
lines changed

manifests/agent.pp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# ['puppet_agent_service'] - The service the puppet agent runs under
99
# ['puppet_agent_package'] - The name of the package providing the puppet agent
1010
# ['version'] - The version of the puppet agent to install
11-
# ['puppet_run_style'] - The run style of the agent either cron or service
11+
# ['puppet_run_style'] - The run style of the agent either 'service', 'cron', 'external' or 'manual'
1212
# ['puppet_run_interval'] - The run interval of the puppet agent in minutes, default is 30 minutes
1313
# ['user_id'] - The userid of the puppet user
1414
# ['group_id'] - The groupid of the puppet group
@@ -85,7 +85,7 @@
8585
$startonboot = 'no'
8686
}
8787

88-
if ($::osfamily == 'Debian') or ($::osfamily == 'Redhat') {
88+
if ($::osfamily == 'Debian' and $puppet_run_style != 'manual') or ($::osfamily == 'Redhat') {
8989
file { $puppet::params::puppet_defaults:
9090
mode => '0644',
9191
owner => 'root',
@@ -101,7 +101,6 @@
101101
require => Package[$puppet_agent_package],
102102
owner => $::puppet::params::puppet_user,
103103
group => $::puppet::params::puppet_group,
104-
notify => Service[$puppet_agent_service],
105104
mode => '0655',
106105
}
107106
}
@@ -135,18 +134,25 @@
135134
$service_ensure = 'stopped'
136135
$service_enable = false
137136
}
137+
# Do not manage the Puppet service and don't touch Debian's defaults file.
138+
manual: {
139+
$service_ensure = undef
140+
$service_enable = undef
141+
}
138142
default: {
139143
err 'Unsupported puppet run style in Class[\'puppet::agent\']'
140144
}
141145
}
142146

143-
service { $puppet_agent_service:
144-
ensure => $service_ensure,
145-
enable => $service_enable,
146-
hasstatus => true,
147-
hasrestart => true,
148-
subscribe => File [$::puppet::params::puppet_conf],
149-
require => Package[$puppet_agent_package],
147+
if $puppet_run_style != 'manual' {
148+
service { $puppet_agent_service:
149+
ensure => $service_ensure,
150+
enable => $service_enable,
151+
hasstatus => true,
152+
hasrestart => true,
153+
subscribe => [File[$::puppet::params::puppet_conf], File[$::puppet::params::confdir]],
154+
require => Package[$puppet_agent_package],
155+
}
150156
}
151157

152158
if ! defined(File[$::puppet::params::puppet_conf]) {
@@ -156,7 +162,6 @@
156162
require => File[$::puppet::params::confdir],
157163
owner => $::puppet::params::puppet_user,
158164
group => $::puppet::params::puppet_group,
159-
notify => Service[$puppet_agent_service],
160165
}
161166
}
162167
else {

spec/system/agent_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,27 @@ class { 'puppet::agent':
6868
# by the agent module.
6969
it { should have_entry "* * * * \/usr\/bin\/puppet agent --no-daemonize --onetime --logdest syslog > \/dev\/null 2>&1" }
7070
end
71+
end
72+
73+
context 'agent run style manual' do
74+
it 'should work with no errors' do
75+
pp = <<-EOS
76+
class { 'puppet::agent':
77+
puppet_run_style => 'manual',
78+
}
79+
EOS
80+
81+
# Run it twice and test for idempotency
82+
puppet_apply(pp) do |r|
83+
r.exit_code.should_not == 1
84+
r.refresh
85+
r.exit_code.should be_zero
86+
end
87+
end
7188

89+
describe package('puppet') do
90+
it { should be_installed }
91+
end
7292
end
7393

7494
context 'agent with external scheduler' do

0 commit comments

Comments
 (0)