Git Product home page Git Product logo

Comments (9)

lucywyman avatar lucywyman commented on June 5, 2024 2

There isn't currently, but I think we can have a way to expose that.

The Solution

This should be a new subcommand bolt groups show, which will need a new elsif in this block: https://github.com/puppetlabs/bolt/blob/master/lib/bolt/cli.rb#L291-L311. That should call a new function in cli.rb called list_groups, which should be defined right after the def list_targets definition and look like this:

def list_groups
  groups = inventory.group_names
  outputter.print_groups(groups)
end

Then we'll need to define simple formatted output in both the JSON and human outputters (https://github.com/puppetlabs/bolt/tree/master/lib/bolt/outputter).

Testing should include printing nothing when the inventory is empty, and test for inventory versions 1 and 2.

from bolt.

adreyer avatar adreyer commented on June 5, 2024

To keep this aligned with the behavior of the task and plan show commands it should be:

$bolt group show
mygroup_01
mygroup_02
mygroup_03
$bolt group show mygroup_01
foo-001
foo-002
foo-003

If the goal is autocompletion should the object be groups or targets?

bolt target show
mygroup_01
mygroup_02
mygroup_03
foo-001
foo-002
foo-003

Latter bolt target show mygroup_01 could be added to show more info about the group itself.

from bolt.

scoopex avatar scoopex commented on June 5, 2024

Sounds good :-)

from bolt.

lucywyman avatar lucywyman commented on June 5, 2024

We now have a command bolt inventory show (https://puppet.com/docs/bolt/latest/bolt_command_reference.html#inventory-show) which accepts a TargetSpec and lists nodes that match that spec. This includes listing groups in the inventory, so bolt inventory show -n mygroupname will list nodes in that group. Let me know if this issue needs to be reopened.

from bolt.

scoopex avatar scoopex commented on June 5, 2024

Clone the recent repository: https://github.com/puppetlabs/bolt and executed bolt directly in the repository.

Played around with the first example of https://puppet.com/docs/bolt/latest/inventory_file.html#inventory-facts-vars-and-features

How can i gather the list of group-names? (this is essential for the bash completion)

Also other things are working not in a expected way:

# ok
$ bolt inventory show -n all
10.23.27.148
10.23.27.149
10.23.27.150
10.23.27.151
10.23.27.152
10.23.27.153
10.23.27.154
10.23.27.155

# wrong: result should be  192.168.100.179, 192.168.100.180, 192.168.100.181
$ bolt inventory show -n webservers
webservers
1 target

# wrong: result should be 192.168.100.179, 192.168.100.180, 192.168.100.181,192.168.101.50, 192.168.101.60
$ bolt inventory show -n ssh_nodes
ssh_nodes
1 target

# wrong: execution should be on 192.168.100.179, 192.168.100.180, 192.168.100.181,192.168.101.50
$ bolt command run "uptime" -n ssh_nodes
Started on ssh_nodes...
Failed on ssh_nodes:
  Failed to connect to ssh_nodes: getaddrinfo: Name or service not known
Failed on 1 node: ssh_nodes
an on 1 node in 0.1 sec

from bolt.

lucywyman avatar lucywyman commented on June 5, 2024

Can you post a (scrubbed) version of your inventory? Are you using inventory version 1 or 2?

from bolt.

lucywyman avatar lucywyman commented on June 5, 2024

It's working as expected for me locally with both inventory v1 and v2...

from bolt.

scoopex avatar scoopex commented on June 5, 2024

I am sorry, i accidentally placed the example to ~/.bolt/inventory.yaml.
The correct location "~/.puppetlabs/bolt/inventory.yaml" contained a outdated file.

Probably it is a good idea to enhance the last line "x targets" with the origin of the targets.
(i.e. '12 targets, loaded from "~/.puppetlabs/bolt/inventory.yaml" ')

How can i query the list of group-names? (this is essential for shell completion)

from bolt.

genebean avatar genebean commented on June 5, 2024

Probably it is a good idea to enhance the last line "x targets" with the origin of the targets.
(i.e. '12 targets, loaded from "~/.puppetlabs/bolt/inventory.yaml" ')

^^ would be a great addition too.

from bolt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.