Jira (BOLT-1384) Inventory command

16 views
Skip to first unread message

Corey Osman (JIRA)

unread,
Jun 11, 2019, 7:34:03 PM6/11/19
to puppe...@googlegroups.com
Corey Osman created an issue
 
Puppet Task Runner / New Feature BOLT-1384
Inventory command
Issue Type: New Feature New Feature
Assignee: Unassigned
Created: 2019/06/11 4:33 PM
Priority: Normal Normal
Reporter: Corey Osman

I would like to have an inventory command to interact with the inventory file, puppetdb or other place bolt retrieves the list of nodes from.

This would allow me to see what is in the inventory before running and also write bootstrap scripts outside of bolt

This command would prevent me from having to always parse out the inventory file to accomplish the same thing.

Example:

 

#!/usr/bin/env bash
 
nodes=$(bolt inventory --nodes ubuntu)
for node in $nodes; do
  ssh-copy-id ethos@${nodes}
done

 

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Tom Beech (JIRA)

unread,
Jul 25, 2019, 1:33:03 PM7/25/19
to puppe...@googlegroups.com
Tom Beech commented on New Feature BOLT-1384
 
Re: Inventory command

A `bolt inventory show` command was added in 1.26.0 and supports human and json format. (https://puppet.com/docs/bolt/latest/bolt_new_features.html#section-fh3-j5c-j3b)

Does this satisfy your use case?

 

Corey Osman (JIRA)

unread,
Jul 25, 2019, 2:51:03 PM7/25/19
to puppe...@googlegroups.com
Corey Osman commented on New Feature BOLT-1384
 
Re: Inventory command

This does satisfy my use case.  Just tried this out.

However,  this creates a new problem in that the node count at the bottom will cause any script written against the output of the inventory command to break.  The node count should be removed by default or added as a option.

192.168.70.104
192.168.70.110
192.168.70.119
192.168.70.125
192.168.70.128
192.168.70.135
192.168.70.136
55 targets

Alex Dreyer (JIRA)

unread,
Aug 2, 2019, 4:17:03 PM8/2/19
to puppe...@googlegroups.com
Alex Dreyer commented on New Feature BOLT-1384
 
Re: Inventory command

Does --format=json work?

Corey Osman (JIRA)

unread,
Aug 2, 2019, 4:20:03 PM8/2/19
to puppe...@googlegroups.com
Corey Osman commented on New Feature BOLT-1384
 
Re: Inventory command

I would need --format=text, --format=json

I would prefer to just have the node count removed by default.  Use a verbose option if you want the count.

Lucy Wyman (JIRA)

unread,
Aug 12, 2019, 2:50:03 PM8/12/19
to puppe...@googlegroups.com
Lucy Wyman commented on New Feature BOLT-1384
 
Re: Inventory command

Corey Osman What's your use case? I don't follow why –format json doesn't work. You could theoretically use tee to send the output to another stream / file, if you want to both read it and consume it. Is the human formatting what you need for it to be consumed?

Alex Dreyer (JIRA)

unread,
Aug 12, 2019, 6:32:03 PM8/12/19
to puppe...@googlegroups.com
Alex Dreyer commented on New Feature BOLT-1384
 
Re: Inventory command

This seems like a usecase for the often discussed `--format oneline`

Corey Osman (JIRA)

unread,
Aug 12, 2019, 7:01:05 PM8/12/19
to puppe...@googlegroups.com
Corey Osman commented on New Feature BOLT-1384
 
Re: Inventory command

IMHO, the default usage of this command will be for scripts.  If that is the case we should make the default behavior work for the scripts and not against them.

So in a case like:

#!/usr/bin/env bash nodes=$(bolt inventory --nodes ubuntu) for node in $nodes; do ssh-copy-id ethos@${nodes} done

I don't want to go hunt down which modifier I need to add in order to not return "55 targets".  I also don't want to run the command first only to have it fail on the node called "55" and "targets".  So I would like to have this count removed by default. 

 

Alex Dreyer (JIRA)

unread,
Aug 12, 2019, 7:15:02 PM8/12/19
to puppe...@googlegroups.com
Alex Dreyer commented on New Feature BOLT-1384
 
Re: Inventory command

I don't think just removing the final line is a good long term solution. We intended to solve multiple use cases with the fix we added one of which was predicting what target a bolt command would run on. In that case the count is useful. 

In general the default "human" output for bolt is not intended to be stable for consumption from bash scripts which is why we've discussed a "oneline" format in the past. If we do add oneline support for this feature we should make sure to add some information beyond the 'name' to force the user to use cut in the initial release otherwise we'll likely break the output in the future.

Reply all
Reply to author
Forward
0 new messages