Users should be able to include external Puppetfiles in their own. #927
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related: #885
Hello!
💁♀️ This PR adds a new
incl
syntax to thePuppetfile
spec for including an external Puppetfile as if it were part of the environments dependencies.Sample Puppetfile:
Sample External Puppetfile at
/usr/local/share/r10k/Puppetfile
:In our environment, we have multiple tenants separated into separate control repositories. Some of these tenants depend on shared modules (roles/profiles) we maintain as a community. This means that when we decide to update underlying component modules, we have to communicate those changes to individual tenants and it creates a release bottleneck.
One "hack" that we've been using in the last year was to have our r10k node write the "shared upstream
Puppetfile
" to disk and then in tenantPuppetfile
, they do the following:The fact that
Puppetfile
areeval()-d
as Ruby currently allows us to solve the problem. IIn #885, an AST-based approach is proposed for hosts running Ruby 2.6+. If this were the standard behaviour, then our eval-based approach to sharing modules would break. My proposal is based on the implementation @binford2k provides in #885 and adds new syntax to officially support inclusion of an external
Puppetfile
.Implementation Details / Credits
incl
. The directive receives a single argument that can be a relative or absolute path. If a relative path is used, it is relative to the callingPuppetfile
.Puppetfile
.Please let me know if you have any questions. I will be adding additional unit tests to cover this code, but wanted to get this PR submitted. I appreciate your time and consideration!