Skip to content

Allow -t/--targets to accept JSON array on stdin #121

@jay7x

Description

@jay7x

Use Case

I'd like to filter nodes in the inventory with a plan and pass the node list to another plan as a targets list. For example:

bolt plan run inventory::filter variable=pp_role value=sandbox | \
bolt plan run example::foo -t-

The only value bolt plan run prints on stdout is the plan result value, which is always printed as JSON:

bolt plan run inventory::filter variable=pp_role value=sandbox
[...]
[
  "node1.example.tld",
  "node2.example.tld",
]

Describe the Solution You Would Like

With all the above in mind, the best solution is to teach bolt -t- to understand if JSON is given on stdin, I guess.

Describe Alternatives You've Considered

  1. Use jq -r between bolt invocations to convert from JSON array to the plain text list.
  2. Use --params=- instead of -t- and pass targets there.. Though, it makes passing other parameters to the 2nd plan much more complicated. One need to merge JSON documents for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions