You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes I'd like to run a command or task on a subset of my inventory, that is based on a Target facts or variables. Currently there is no way to do so. You can read this as "I miss mco filters" :)
Describe the Solution You Would Like
We can add the -F, --filter <filter_expression> CLI option, where <filter_expression> is a Puppet DSL expression to be evaluated for every Target object we got from --query or --targets CLI option.
Actually, the filtering logic is like the following:
That can open some security issues, because anything can be evaluated there.. though being able to evaluate anything is the main idea actually. From other side, it should be possible to expose only $target variable scope when filtering. Nobody prevents user from using generate() inside though.
Few examples:
# Run `racadm ...` on Dell servers only (based on `bmc_type` target variable set in inventory)
bolt command run 'racadm ...' -t servers --filter '$target.vars["bmc_type"] == "idrac"'# Run `apt update` on Debian servers only (based on facts)# This is sub-optimal, because "facts" plan should be called once for all targets ideally
bolt command run 'apt update' -t all --filter 'run_plan("facts", $target); $target.facts["os.family"] == "Debian"'
WRT facts query above, it might be profitable to add another CLI option (--filter-facts?) to pre-collect facts from targets specified first, then do the filtering.
Describe Alternatives You've Considered
It's not that critical for plans, because there I can filter targets easily. But I don't want to create plans for every ad-hoc one-liner. Also I cannot create a generic plan to filter targets, because there is no way to evaluate a String as a Puppet DSL expression (or I'm not aware of it).
The text was updated successfully, but these errors were encountered:
Use Case
Sometimes I'd like to run a command or task on a subset of my inventory, that is based on a Target facts or variables. Currently there is no way to do so. You can read this as "I miss
mco
filters" :)Describe the Solution You Would Like
We can add the
-F, --filter <filter_expression>
CLI option, where<filter_expression>
is a Puppet DSL expression to be evaluated for every Target object we got from--query
or--targets
CLI option.Actually, the filtering logic is like the following:
That can open some security issues, because anything can be evaluated there.. though being able to evaluate anything is the main idea actually. From other side, it should be possible to expose only $target variable scope when filtering. Nobody prevents user from using
generate()
inside though.Few examples:
WRT facts query above, it might be profitable to add another CLI option (
--filter-facts
?) to pre-collect facts from targets specified first, then do the filtering.Describe Alternatives You've Considered
It's not that critical for plans, because there I can filter targets easily. But I don't want to create plans for every ad-hoc one-liner. Also I cannot create a generic plan to filter targets, because there is no way to evaluate a String as a Puppet DSL expression (or I'm not aware of it).
The text was updated successfully, but these errors were encountered: