Ok, so I ended up compromising between Seth’s plan and mine.
The option name is still -p, but I’ve renamed the long form --host-pattern. -h is taken by opt parse for --help
The inventory file is now -i
-p options can be separated by semicolons and can be either host patterns (matching any host in the inventory file) or group names from the inventory file
I didn’t allow targeting hosts not in the file, because I believe this results in a confusing scenario if you typo a pattern or a group name, and it’s not readily apparent
nothing is matched.
I’ve updated the README and docs to reflect this.
It also seems we can eliminate “-a” if we use the unmatched args, so I’m working to incorporate that from Seth’s earlier patches. I also think defaulting -n to command is pretty elegant.
It bothers me that the default pattern is “*”, as that seems a thermonuclear option. So I am going to REQUIRE a value be supplied for -p. No default.
AKA:
ansible rm -rf /srv
VS
ansible -p “webservers” rm -rf /srv
In the latter, you made a conscious decision about what you were going to target. That walks a bit of a line between being crazy useful and very easy to shoot your foot off with.
–Michael