New at ansible… Have used “pdsh” a lot. In pdsh, assuming it uses the default host list, if I want to run the same command on all hosts. I say something like
‘pdsh ’
If I want to run on only a few hosts, I could run
‘pdsh -w “host[1-5,7,9], doggy23” ’
- That will run on host1, host2, host3, host4, host5, host7, host9 and doggy23
However, often I want to run on all the hosts EXCEPT a few that, say are dead, or I already ran the command on to test it, or whatever. To do that in pdsh, I could run:
‘pdsh -x “host2, host4, doggy33, kitty[4-6]” ’
That would run on all hosts in the hostlist, EXCEPT host2, host4, doggy33, kitty4, kitty5 and kitty6
How, in ansible, in a command line, one-off, (maybe called “ad-hoc”?) way can I do the above without making a new group or list with just the hosts I do not want to run on, can I do the above?
I believe if I do “ansible ‘dog*’ --list-hosts” it will only run on the hosts that start with “dog” in the list-hosts. But I have had mixed results with stuff like:
‘ansible ‘all:!doggy2:doggy5:host3*’ --list-hosts’
‘ansible ‘all:!doggy2:!doggy5:!host3’ --list-hosts’
'ansible ‘all:!doggy2:!doggy5:!host3*’ --list-hosts’ {In cshell}
But it seems a little “messy” and, as you can see.
Is there a “Exclude” option like the “-x” in pdsh? Some thing like
‘ansible ‘all:!doggy[2,5]:!host3’ -list-hosts ’
or better: