Skip to content

Commit d7ee9e5

Browse files
committed
Parameter for setting final state of agents
Provides a parameter in plans peadm::install and peadm::subplans::configure which can be used to set the final state of the puppet agent which runs on infrastructure nodes. Allows for stopped or running states only.
1 parent 092812d commit d7ee9e5

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

plans/install.pp

+9-4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
# The parameter should be set to a valid set of connection settings as
2222
# documented for the PE RBAC /ds endpoint. See:
2323
# https://puppet.com/docs/pe/latest/rbac_api_v1_directory.html#put_ds-request_format
24+
# @param final_agent_state
25+
# Configures the state the puppet agent should be in on infrastructure nodes
26+
# after PE is configured successfully.
2427
#
2528
plan peadm::install (
2629
# Standard
@@ -56,10 +59,11 @@
5659
Optional[String] $license_key_content = undef,
5760

5861
# Other
59-
Optional[String] $stagingdir = undef,
60-
Enum[direct,bolthost] $download_mode = 'bolthost',
61-
Boolean $permit_unsafe_versions = false,
62-
String $token_lifetime = '1y',
62+
Optional[String] $stagingdir = undef,
63+
Enum['running', 'stopped'] $final_agent_state = 'running',
64+
Enum['direct', 'bolthost'] $download_mode = 'bolthost',
65+
Boolean $permit_unsafe_versions = false,
66+
String $token_lifetime = '1y',
6367
) {
6468
peadm::assert_supported_bolt_version()
6569

@@ -121,6 +125,7 @@
121125

122126
# Other
123127
stagingdir => $stagingdir,
128+
final_agent_state => $final_agent_state,
124129
)
125130

126131
# Return a string banner reporting on what was done

plans/subplans/configure.pp

+14-6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
# @param ldap_config
1717
# This hash contains the options necessary for configuring the LDAP
1818
# connection on the main server.
19+
# @param final_agent_state
20+
# Configures the state the puppet agent should be in on infrastructure nodes
21+
# after PE is configured successfully.
1922
#
2023
plan peadm::subplans::configure (
2124
# Standard
@@ -30,15 +33,16 @@
3033
Optional[Peadm::SingleTargetSpec] $replica_postgresql_host = undef,
3134

3235
# Common Configuration
33-
String $compiler_pool_address = $primary_host.peadm::certname(),
36+
String $compiler_pool_address = $primary_host.peadm::certname(),
3437
Optional[String] $internal_compiler_a_pool_address = undef,
3538
Optional[String] $internal_compiler_b_pool_address = undef,
36-
Optional[String] $token_file = undef,
37-
Optional[String] $deploy_environment = undef,
38-
Optional[Peadm::Ldap_config] $ldap_config = undef,
39+
Optional[String] $token_file = undef,
40+
Optional[String] $deploy_environment = undef,
41+
Optional[Peadm::Ldap_config] $ldap_config = undef,
3942

4043
# Other
41-
String $stagingdir = '/tmp',
44+
String $stagingdir = '/tmp',
45+
Enum['running', 'stopped'] $final_agent_state = 'running'
4246
) {
4347
# TODO: get and validate PE version
4448

@@ -147,7 +151,11 @@
147151
}
148152

149153
# Ensure Puppet agent service is running now that configuration is complete
150-
run_command('systemctl start puppet', peadm::flatten_compact([
154+
$systemctl_state = $final_agent_state ? {
155+
'running' => 'start',
156+
'stopped' => 'stop'
157+
}
158+
run_command("systemctl ${systemctl_state} puppet", peadm::flatten_compact([
151159
$primary_target,
152160
$replica_target,
153161
$primary_postgresql_target,

0 commit comments

Comments
 (0)