- SIMP-3479Getting issue details... STATUS
Managing Multiple Puppet environments (without SIMP)
Control repositories
Outside of SIMP, Git-based control repositories have been the dominant technology to manage and deploy Puppet code since 2015. At a high-level, this workflow involves:
- A Puppetfile that defines a collection of Puppet modules and where to get them
- A (Git) Control repository, where each branch defines a complete Puppet environment (which includes a Puppetfile)
- A tool (r10k or PE Code Manager) to deploy Puppet environments from the control repository branches
- (Advanced, but preferred) Repository webhooks that automatically trigger environment deployments on the Puppet master(s) whenever a branch is updated.
The upshot is that a control repository branch defines everything needed to recreate a specific Puppet environment.
Puppet environments as code
A branch contains everything required to recreate a Puppet environment, so Puppet Environments can be treated like code:
- (Using r10k/Code Manager,) Adding or removing a git branch will add or remove that environment on the Puppet master(s)
- Puppet environment updates can be submitted as merge/pull requests
- User can test, diff, and review changes before promoting them into important environments
- When branches are updated, CI pipelines can automatically trigger tests and deployments
Multiple environments using Control repositories
Since 1 control repo branch = 1 Puppet environment, managing multiple Puppet environments is as simple as using git:
- To create a temporary testing (canary) environment, fork an existing branch
- Once the canary branch is validated, merge it back
- Control write access to important permanent environments by protecting their branches.
Control repos + Puppet deployment tools enable advanced environment scenarios:
- (r10k, Code Manager:) Deploy consistent Puppet environments across Puppet architectures that involve multiple masters
- (Bolt:) Manage remote "agentless" hosts by checking out an environment's modules (using
bolt puppetfile install
) before runningbolt apply
SIMP + Multiple Puppet environments
Limitations and conflicts
Although it has been technically possible to use multiple Puppet environments and control repositories since SIMP 5.0 (SIMP 5.0-6.3), in practice this has been cumbersome, risky, and easy to get wrong. Getting it right requires an in-depth knowledge of Puppet environments and SIMP's "extra" environments, and there are still significant limitations.
The recent 6.4.0 release (SIMP 6.4) retooled SIMP so it can safely support single-environment Puppetfile deployments (e.g., r10k puppetfile install
from a Puppet environment directory) out of the box. However, there are still two major sources of conflicts with multiple Puppet environments:
Issue 1: SIMP automation alters files under the Puppet and SIMP environment directories
- SIMP 5.0-6.3 RPM updates and
simp_rpm_helper
could modify existing files Puppet and SIMP environment directories - SIMP 5.0-6.3 User-initiated tools like
simp config could modify existing files Puppet and SIMP environment directories
- SIMP 6.4 PARTIALLY FIXED The user-initiated tool
simp environment new
can ensure that there is a corresponding secondary and writable environments- This is a safety improvement from earlier releases, because it will only alter environment files when the user initiates it
- However, the
simp environment
tool is only partially implemented, and the rest cannot be implemented safely. - As things stand, this means SIMP 6.4.0:
- Safely supports SIMP extra data with the Local (Puppetfile-only) deployment scenario with a single environment (production)
- Does not safely support SIMP extra data with the Control Repository deployment scenarios (without additional conventions and limitations)
Issue 2: SIMP expects there to be separate Secondary and Writable assets to complement each Puppet environment
SIMP has always assumed that there will be two SIMP-specific "environment" data directories to complement each Puppet environment directory
- SIMP (ALL) "Secondary" data/assets under
/var/simp/environments/$environment/.
These are files too sensitive and/or too large to check into git in plaintext, maintained by site admins.- "Site Files" modules, like
pki_files
(keydist) andkrb3_files
. - The FakeCA support script, including the FakeCA's private key
- RSync directories, used by the
simp::server::rsync_shares
profile to serve files for various modules.
- "Site Files" modules, like
- SIMP (ALL) "Writable" data/assets under under
/opt/puppetlabs/server/data/puppetserver/simp/environments/$environment/
These are secrets, read by certain Puppet functions while compiling catalogs (and automatically generated if they are missing).
There are only two Puppet functions in SIMP that use the writeable environment directory:simplib::passgen()
- a popular function, used to generate secret passwords
- Used in 14 SIMP modules—usually (but not always) exposed as a parameter default
- Secrets read by this function can also be generated by the
simp passgen
CLI tool
ssh::autokey()
—this function is unused by the stock SIMP modules, but is provided to allow local admins to automatically set up SSH keys as needed.
SIMP 6.4.0: Deploy single environment from a Puppetfile
SIMP 6.4.0 addressed many of tool and RPM-related problems by making Puppetfile-based module deployments the preferred method to deploy modules.
- Puppetfile-based deployment tools like r10k or Code Manager and now preferred to deploy SIMP's Puppet modules
- To prevent conflicts with these tools, SIMP no longer interferes with any files under the Puppet or SIMP environment directories, unless directed to by the user.
- SIMP module RPMs now install tagged versions into local git repositories, for use in local Puppetfiles
- The
simp puppetfile
tool was introduced to automatically generate Puppetfiles based on the current module RPMs.
- The
- The
simp environment new
tool was introduced to help users ensure that corresponding SIMP and Puppet environments are created.
Improvements focused on making it simple to use Puppetfiles in a single environment, with multiple
made it simple to deploy environments, but they didn't make them safe.
During the development of SIMP 6.4.0, it became apparent that the simp environment
workflow would have problems down the road:
- Making a new SIMP writable and secondary environment for ever Puppet environment was arbitrary
- The dependence on
$environment
made it necessary to adopt workarounds like `simp environment new [--copy|--link
]` when environments used the same (or similar) resources - Linked
- The dependence on
- It would be too easy to permanently lose data from linked environments with the proposed
simp environment rm
command