-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
This checks if a user configured a environment in pe.conf. If that's the case, it will be used for the PEADM-specific node groups. Otherwise we fall back to production. This fixes a timing issue discovered in #469. In situations where the PE infra isn't running in production, we cannot assume that a production environment exists. And a node group can only reference classes from the environment the node group belongs to.
- Loading branch information
1 parent
ab9db39
commit e6092ff
Showing
14 changed files
with
186 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# | ||
# @summary check if a custom PE environment is set in pe.conf | ||
# | ||
# @param primary the FQDN for the primary, here we will read the pe.conf from | ||
# | ||
# @return [String] the desired environment for PE specific node groups | ||
# | ||
# @see https://www.puppet.com/docs/pe/latest/upgrade_pe#update_environment | ||
# | ||
# @author Tim Meusel <[email protected]> | ||
# | ||
function peadm::get_node_group_environment(Peadm::SingleTargetSpec $primary) { | ||
$peconf = peadm::get_pe_conf(get_target($primary)) | ||
# if both are set, they need to be set to the same value | ||
# if they are not set, we assume that the user runs their infra in production | ||
$pe_install = $peconf['pe_install::install::classification::pe_node_group_environment'] | ||
$puppet_enterprise = $peconf['puppet_enterprise::master::recover_configuration::pe_environment'] | ||
|
||
# check if both are equal | ||
# This also evaluates to true if both are undef | ||
if $pe_install == $puppet_enterprise { | ||
# check if the option isn't undef | ||
# ToDo: A proper regex for allowed characters in an environment would be nice | ||
# https://github.com/puppetlabs/puppet-docs/issues/1158 | ||
if $pe_install =~ String[1] { | ||
return $pe_install | ||
} else { | ||
return 'production' | ||
} | ||
} else { | ||
fail("pe_install::install::classification::pe_node_group_environment and puppet_enterprise::master::recover_configuration::pe_environment need to be set to the same value, not '${pe_install}' and '${puppet_enterprise}'") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.