Coder Social home page Coder Social logo

Comments (11)

MikaelSmith avatar MikaelSmith commented on May 30, 2024 2

This should work with bolt command run "df -h" --nodes=ceph-cluster-{001..111}.

from bolt.

MikaelSmith avatar MikaelSmith commented on May 30, 2024 2

That seems like a promising possibility.

from bolt.

lucywyman avatar lucywyman commented on May 30, 2024

You may already have this workaround in place, but in the meantime you can use

bolt command run "df -h" -n `echo ceph-cluster-{001..111} | tr '  ' ,`

from bolt.

MikaelSmith avatar MikaelSmith commented on May 30, 2024

We use something similar as an example in https://puppet.com/docs/bolt/0.x/bolt_options.html#concept-743.

from bolt.

scoopex avatar scoopex commented on May 30, 2024

This is not the same, because it adds multiple --nodes arguments using shell expansion.
Using a single --nodes argument with number of hosts separated by spaces provides a additional (and for many users useful) possibility.

$ echo bolt command run "la" --nodes={web{5,6,7},elasticsearch{1,2,3}.subdomain}.mydomain.edu  
bolt command run la --nodes=web5.mydomain.edu --nodes=web6.mydomain.edu --nodes=web7.mydomain.edu --nodes=elasticsearch1.subdomain.mydomain.edu --nodes=elasticsearch2.subdomain.mydomain.edu --nodes=elasticsearch3.subdomain.mydomain.edu

from bolt.

MikaelSmith avatar MikaelSmith commented on May 30, 2024

I missed the awk example, which wouldn't work with what I suggested. But it would work with

awk '/Host ceph-mon/{print $2}' ~/.ssh/config | bolt command run "df -h" -n -

-n - reads from stdin, and will accept whitespace-separated hostnames.

from bolt.

MikaelSmith avatar MikaelSmith commented on May 30, 2024

I'm resistant to supporting multiple arguments to --nodes because it makes CLI parsing more complicated and can make it harder to provide clear errors. I believe the use cases you're interested are all possible, just in slightly different forms than you expected.

from bolt.

scoopex avatar scoopex commented on May 30, 2024

I think i understand your argument. But you should also consider that using node names separated by spaces gains a lot of convenience for at least unix/linux users.

Typical shell expansion / usage works without hacky conversion tricks (pipes, subshells, ...)

from bolt.

exic avatar exic commented on May 30, 2024

Would it be an option to treat the "remaining arguments" as nodes? Like this, but without giving "Unknown argument(s)":

bolt command run "docker exec whatever status" -- $(custom_get_hosts --filter node-)
Unknown argument(s) node-01, node-02, node-03, node-04, node-05, node-06, node-07, node-08, node-09, node-10, node-11, node-12, node-13, node-14, node-15, node-16

from bolt.

nicklewis avatar nicklewis commented on May 30, 2024

Since this issue was first opened, Bolt now supports:
a) multiple --target options
b) space-separated target lists (only as a single CLI argument)
c) reading targets from STDIN
d) inventory globbing

That means there are quite a few ways to accomplish this now, depending on the use case:

$ bolt inventory show -t\ foo-{1..10}
$ bolt inventory show -t `echo foo-{1..10}`
$ echo foo-{1..10} | bolt inventory show -t -
$ bolt inventory show -t foo-*

The version specifically requested of the ability to use multiple bare (without a flag prepended) CLI args as targets isn't supported, but I think there are plenty of similar options.

from bolt.

nmaludy avatar nmaludy commented on May 30, 2024

FYI i did some work on this just now, not from the CLI but from an inventory file perspective. In my work you can use ERB to generate some YAML, then the YAML will be parsed and the structured data returned from the plugin. This results in us being able to use ERB to generate a ranges of hosts:

Example inventory:

version: 2
groups:
 - name: hosts_range
   targets:
     _plugin: task
     task: inventory_utils::erb_template
     parameters:
       parse: yaml
       template: |
         <% (0..10).each do |num| %>
         - web<%= '%02d' % num %>.domain.tld
         <% end %>

Example nodes generated and available in Bolt:

$ bolt inventory show --targets hosts_range
web00.domain.tld
web01.domain.tld
web02.domain.tld
web03.domain.tld
web04.domain.tld
web05.domain.tld
web06.domain.tld
web07.domain.tld
web08.domain.tld
web09.domain.tld
web10.domain.tld
11 targets

Reference: https://github.com/EncoreTechnologies/puppet-inventory_utils#inventory_utilserb_template---creating-hosts-ranges

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.