-
Notifications
You must be signed in to change notification settings - Fork 224
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
(GH-1934) Add support for selective sync of plugins to target nodes #1935
(GH-1934) Add support for selective sync of plugins to target nodes #1935
Conversation
05b0a1f
to
0ad502e
Compare
CLA signed by all contributors. |
I don't think there is a good argument for allowing this to be set per target. It makes more sense as a global setting that is used for all targets. |
In our current use-case, we have multiple nodes with different roles and we run different bolt tasks on them. Each bolt task has a specific set of modules it needs. Setting it globally means all nodes would get the same set of modules. Although that would probably help a bit, this implementation gives you maximum control. |
lib/bolt/applicator.rb
Outdated
end | ||
|
||
private def libexec | ||
@libexec ||= File.join(Gem::Specification.find_by_name('bolt').gem_dir, 'libexec') | ||
end | ||
|
||
def selected_module?(mod) | ||
@selected_modules.any? { |m| mod =~ /#{m}/ } |
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.
@selected_modules.any? { |m| mod =~ /#{m}/ } | |
@selected_modules.include?(mod) |
This will more accurately select the exact module, not ones that include the modulename. For example if I have module nginx
and call selected_module?('nginx-config')
this will return true.
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.
The idea was to have an array of regular expressions, to make it easy to select multiple modules. So I put it there explicitly. For example, the augueas provides can be added like this:
['augeasproviders_.*']
Personally I prefer this above specifying all modules individually.
I'm concerned that scoping this to nodes and trying to track exactly what is managed on each node is going to quickly become unmaintainable for many users and introduces new performance issues on the bolt controller around building multiple plugin bundles. This it works tolerably well in the case where you are applying roles to servers and can try to set which modules are needed for each role. But you're still left tracking the role assignment and module code separately from the plugin bundle mapping . What happens when a user wants to run a plan that goes outside of these bounds if a fact is simply not synced things may behave unexpectedly. |
@adreyer I understand your concern regarding maintainability. On the other hand, I guess that goes for all features. Always use it moderate and wise. Although you could add this to the inventory, I think it is best used in the plan by calling
just before applying the puppet block. This way it keeps the selection close to the puppet code and keeps everything as neat as possible. Missing a module would be the same as missing a module in the Puppetfile. When the I see this feature a bit like setting the I have been thinking about using a variable, but because it is functionally so close to a feature, I thought it best to use a config setting. Regarding performance: I'm not sure what the impact is on large sets of nodes. If this is an issue, we could always optimize this. |
I was imagining this being set in the inventory file. If the plan author is expected to control this it seems much more natural as a parameter to |
Functionality that sounds like a great idea! I'll have a look at how we can implement this. |
I think it's best if this feature starts off fairly simple and with the understanding that as a performance optimization it may be ignored/deprecated later. For that reason I think we should name it something like "required_modules" and have it be an explicit list of modules. While a regex may be convienent it seems primarily to be be an issue for augeus providers.
Limiting this further by target may be a further optimization to this but there isn't really a good syntax for that in the plan language. We have per target parameters for |
d55ffca
to
e3eb677
Compare
@adreyer @lucywyman The latest force commit contains the implementation as discussed |
CLA signed by all contributors. |
b7f8852
to
0461279
Compare
I think this is just about ready. My only comment is that in order for this to show up in our changelog, your commit needs to have a message after the
|
@lucywyman I can squash all commits and change the text. Is that what you want, or do you want to retain the editing history in the PR? |
Squash and edit would be great! |
0461279
to
38549dc
Compare
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.
The newly added variables should be locals and not instance variables. Instance variables aren't meaningful for functions and we explicitly don't want it to be part of the shared Applicator instance for the apply()
block case since you may run multiple apply()
statements in a single plan and they can each have their own required modules. The way it's written now, those variables will just be overridden next time so it's not technically broken, but it makes the data lifecycle confusing to follow.
Other than that one detail, this looks great! Thank you for handling the implementation.
…et nodes * **Added support for selective sync of plugins to target** ([puppetlabs#1934](puppetlabs#1934)) !feature This feature allows a plan author to specificy what plugins need to be synced to the target node. You can do this by add an array of module names to the options parameter. Here is an example: apply($target, ‘required_modules => [‘stdlib’] ) { notice 'Hallo' } The apply block here ony sync’s the stdlib module to the target. The same feature also works on apply_prep functions. Here is an example: apply_prep($target, ‘required_modules => [‘stdlib’] ) When no required modules are specified, *ALL* plugins from *ALL* modules are synced.
38549dc
to
3e0fe7f
Compare
@nicklewis I force pushed these changes |
Implement feature request #1934