Dynamic environment interpolation in puppet master configuration
|Affected Puppet version:||development||Branch:|
|Keywords:||dynamic environment, puppet master configuration, interopolated configuration, environment parameter|
In providing a single Puppet master to multiple teams, where each team has their own test/release cadence, we maintain that each team would like to include their own dynamic module path based on the environment passed from the agent. We have a re-usability case where an enterprise level of common modules is provided at the lowest path inclusion priority, the local team has a set of common modules at the next highest level of include priority, and then the dynamic environment has the highest level of inclusion priority. This allows for development and testing cases to be carried out through dynamic pulls of environment-labeled branches in git.
Some form of regex matching of the environment to the configuration section, might help in this regard.
In such a setup it would be nice to configure a puppet master as:
[teama*] manifest = $confdir/environments/manifests/teamb/$environment/site.pp modulepath = $confdir/environments/modules/teamb/$environment/:$confdir/common/modules/teamb/:$confdir/common/modules/enterprise/
[teamb*] manifest = $confdir/environments/manifests/teama/$environment/site.pp modulepath = $confdir/environments/modules/teama/$environment/:$confdir/common/modules/teama/:$confdir/common/modules/enterprise/
…or, alternatively.. such a case where the environment passed in is parsed within the configuration, allowing config-file variables to be set as such:
[production] // passed in $environment = “team-production-product” $group = $environment.split(“–”) // $releasecycle = $environment.split(“–”) // $product = $environment.split(“–”) manifest = $confdir/environments/manifests/$group/$environment/site.pp modulepath = $confdir/environments/modules/$group/$environment/:$confdir/common/modules/$group/:$confdir/common/modules/enterprise/
Within the base environments path, I would initialize the directory as a git repository and keep a post-receive wrapper script to dynamically fetch environments based on the $environment path.