-
Notifications
You must be signed in to change notification settings - Fork 23.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pipe-able --list-hosts output #39003
Comments
BTW: workaround: ansible all --list-hosts | awk 'NR > 1 { print $1 }' |
To do this as described requires dropping the deprecated "optparse" in favor of "argparse" which allows options with zero or more parameters. After that huge lift, this would be a trivial change. And quite useful! The addition of the "hosts (#):" line broke many of our automation scripts when we moved from version <2 on RHEL / Tower, so I for one would be glad to see this change. In the mean time, a separate option could be added to omit the unneeded line and extra spaces, but I like @wookietreiber 's proposed solution better. It doesn't pollute the option namespace with similar related strings. Best would be to simple remove the "hosts (#):" line altogether, as that information could be gotten from a "| wc -l". That would be a truly trivial change now. It seems unlikely that a human or a script would want both at the same time anyway. |
As a workaround you can use a template to list hosts. We should extend |
Thank you very much for your submission to Ansible. It means a lot to us that you've taken time to contribute. Unfortunately, this issue has been open for some time while waiting for a contributor to take it up but there does not seem to have been anyone that did so. So we are going to close this issue to clear up the queues and make it easier for contributors to browse possible implementation targets. However, we're absolutely always up for discussion. Because this project is very active, we're unlikely to see comments made on closed tickets and we lock them after some time. If you or anyone else has any further questions, please let us know by using any of the communication methods listed in the page below: In the future, sometimes starting a discussion on the development list prior to proposing or implementing a feature can make getting things included a little easier, but it's not always necessary. Thank you once again for this and your interest in Ansible! |
disclaimer: I didn't check exactly if this has been reported yet. Searching the issues list for keywords list and hosts just gives back to many results and, frankly, I don't have time to review all 500+ of them.
ISSUE TYPE
COMPONENT NAME
ansible and ansible-playbook command line tools
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
N/A
SUMMARY
The
--list-hosts
option produces formatted output:It would be very useful to have a plain or simple option to this. I propose an output variant that gives just the plain list:
Synopsis:
The text was updated successfully, but these errors were encountered: