Skip to content

Commit 9a7bf4f

Browse files
committed
Add 'manual' puppet_run_style, to not manange the agent service.
1 parent b6f5efd commit 9a7bf4f

File tree

2 files changed

+36
-9
lines changed

2 files changed

+36
-9
lines changed

manifests/agent.pp

Lines changed: 16 additions & 9 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
@@ -83,7 +83,7 @@
8383
$startonboot = 'no'
8484
}
8585

86-
if ($::osfamily == 'Debian') or ($::osfamily == 'Redhat') {
86+
if ($::osfamily == 'Debian' and $puppet_run_style != 'manual') or ($::osfamily == 'Redhat') {
8787
file { $puppet::params::puppet_defaults:
8888
mode => '0644',
8989
owner => 'root',
@@ -132,18 +132,25 @@
132132
$service_ensure = 'stopped'
133133
$service_enable = false
134134
}
135+
# Do not manage the Puppet service and don't touch Debian's defaults file.
136+
manual: {
137+
$service_ensure = undef
138+
$service_enable = undef
139+
}
135140
default: {
136141
err 'Unsupported puppet run style in Class[\'puppet::agent\']'
137142
}
138143
}
139144

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

149156
if ! defined(File[$::puppet::params::puppet_conf]) {

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)