-
Notifications
You must be signed in to change notification settings - Fork 352
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
Add Yaml environment source #983
Conversation
# can be used to designate module content for the environment, independent of | ||
# the base source parameters. | ||
# | ||
# Example: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Start reading here ☝️ for a summary of how it would work
4ff1038
to
1104d5e
Compare
This commit implements a new capability for R10K environment objects: environments can now contain modules directly, when built from an appropriate source type and environment type. Previously, modules could only be attached to an environment by loading an environment, then reading the Puppetfile it contained. This constrained the system because in order for modules to be added, removed, or updated, either the core environment content needed to be changed (the Puppetfile edited), or some kind of magic pattern needed to be specified in the Puppetfile which delegated part of the work of defining a module to an external source (the :control_branch pattern). Now, the framework exists that enables an environment source to add, remove, or update deployed module versions without ever touching or modifying a Puppetfile.
The Hash environment source type is an abstract base class that makes it easy to define environments by simply enumerating them. For example, a REST API could provide a JSON object enumerating each environment that should exist, along with details such as modules to deploy to them. The Hash source baseclass can consume this data and produce the appropriate environments. Note that such a source would no longer need be tightly coupled with version control branches, which is the only way today's r10k sources work.
This commit changes the R10K::Environment::Git class's parent from R10K::Environment::Base to R10K::Environment::WithModules. The practical effect of this is that Git environments are now compatible with environment sources that directly define modules to deploy (in addition to or instead of modules defined in a Puppetfile).
Prior to this fix, the .r10k-deploy.json file wouldn't have a module version in it on first install. It would be present after an upgrade or other modification of an already-present module, just not the first time the module was added to an environment. After this commit, the .r10k-deploy.json file is correctly populated with new-install Forge modules' version numbers.
1104d5e
to
779a8fb
Compare
This allows r10k to read environment definitions from a YAML file, located by default at /etc/puppetlabs/r10k/environments.yaml.
This type has no content besides environment-attached modules
9b64dd5
to
4e57af5
Compare
@reidmv Where would said Also, I'm a fan of the general idea. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@binford2k the For shops that like keeping the content in Git, it could be as simple as a one-file Git repo with a hook to read the latest file on commit. For shops that prefer to be API-driven, either a script could query the API for a hash and write the file as part of a deploy action, or r10k itself could read a hash from the API directly; see the R10k::Source::Hash abstract class for suggestions on how that would be implemented in a later iteration. This is a plumbing feature that user interfaces (such as PE's Code Manager) would build on. |
Makes me wonder if you want |
Yaml source Environment modules Bare environment type
@ekohl Reid's working on an |
Why doesn't this work for SVN? |
As this is currently an experimental feature, SVN support is untested. Focus has been on testing with Git sources. Technically, I think it should partly work for SVN sources. What will likely work is listing an SVN source as an environment in a YAML file. What won't work is specifying individual modules to deploy to that SVN source, as the SVN source type has not been converted from using the Base environment class to using the WithModules environment class. See here. |
Feature demonstration: https://youtu.be/P0lljPd_9L8
Two major ideas here:
Example environments.yaml file: