Skip to content

Parameter for setting final state of agents #305

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 1 commit into from
Oct 20, 2022
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
13 changes: 9 additions & 4 deletions plans/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
# The parameter should be set to a valid set of connection settings as
# documented for the PE RBAC /ds endpoint. See:
# https://puppet.com/docs/pe/latest/rbac_api_v1_directory.html#put_ds-request_format
# @param final_agent_state
# Configures the state the puppet agent should be in on infrastructure nodes
# after PE is configured successfully.
#
plan peadm::install (
# Standard
Expand Down Expand Up @@ -56,10 +59,11 @@
Optional[String] $license_key_content = undef,

# Other
Optional[String] $stagingdir = undef,
Enum[direct,bolthost] $download_mode = 'bolthost',
Boolean $permit_unsafe_versions = false,
String $token_lifetime = '1y',
Optional[String] $stagingdir = undef,
Enum['running', 'stopped'] $final_agent_state = 'running',
Enum['direct', 'bolthost'] $download_mode = 'bolthost',
Boolean $permit_unsafe_versions = false,
String $token_lifetime = '1y',
) {
peadm::assert_supported_bolt_version()

Expand Down Expand Up @@ -121,6 +125,7 @@

# Other
stagingdir => $stagingdir,
final_agent_state => $final_agent_state,
)

# Return a string banner reporting on what was done
Expand Down
20 changes: 14 additions & 6 deletions plans/subplans/configure.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
# @param ldap_config
# This hash contains the options necessary for configuring the LDAP
# connection on the main server.
# @param final_agent_state
# Configures the state the puppet agent should be in on infrastructure nodes
# after PE is configured successfully.
#
plan peadm::subplans::configure (
# Standard
Expand All @@ -30,15 +33,16 @@
Optional[Peadm::SingleTargetSpec] $replica_postgresql_host = undef,

# Common Configuration
String $compiler_pool_address = $primary_host.peadm::certname(),
String $compiler_pool_address = $primary_host.peadm::certname(),
Optional[String] $internal_compiler_a_pool_address = undef,
Optional[String] $internal_compiler_b_pool_address = undef,
Optional[String] $token_file = undef,
Optional[String] $deploy_environment = undef,
Optional[Peadm::Ldap_config] $ldap_config = undef,
Optional[String] $token_file = undef,
Optional[String] $deploy_environment = undef,
Optional[Peadm::Ldap_config] $ldap_config = undef,

# Other
String $stagingdir = '/tmp',
String $stagingdir = '/tmp',
Enum['running', 'stopped'] $final_agent_state = 'running'
) {
# TODO: get and validate PE version

Expand Down Expand Up @@ -147,7 +151,11 @@
}

# Ensure Puppet agent service is running now that configuration is complete
run_command('systemctl start puppet', peadm::flatten_compact([
$systemctl_state = $final_agent_state ? {
'running' => 'start',
'stopped' => 'stop'
}
run_command("systemctl ${systemctl_state} puppet", peadm::flatten_compact([
$primary_target,
$replica_target,
$primary_postgresql_target,
Expand Down