Skip to content
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

Closed
wookietreiber opened this issue Apr 19, 2018 · 4 comments
Closed

pipe-able --list-hosts output #39003

wookietreiber opened this issue Apr 19, 2018 · 4 comments
Labels
affects_2.13 bot_closed feature This issue/PR relates to a feature request. has_pr This issue has an associated PR. inventory Inventory category support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@wookietreiber
Copy link
Contributor

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
  • Feature Idea
COMPONENT NAME

ansible and ansible-playbook command line tools

ANSIBLE VERSION
ansible 2.5.0
  config file = /home/user/projects/ansible/ansible-home/ansible.cfg
  configured module search path = [u'/home/user/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.14 (default, Jan  5 2018, 10:41:29) [GCC 7.2.1 20171224]
CONFIGURATION
DEFAULT_HOST_LIST(/home/user/projects/ansible/ansible-home/ansible.cfg) = [u'/home/user/projects/ansible/ansible-home/hosts']
PERSISTENT_CONNECT_TIMEOUT(/home/user/projects/ansible/ansible-home/ansible.cfg) = 30
OS / ENVIRONMENT

N/A

SUMMARY

The --list-hosts option produces formatted output:

$ ansible all --list-hosts
  hosts (3):
    foo
    bar

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:

$ ansible all --list-hosts=plain
foo
bar

Synopsis:

ansible pattern --list-hosts[={plain|pretty}]
@ansibot ansibot added affects_2.5 This issue/PR affects Ansible v2.5 feature This issue/PR relates to a feature request. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Apr 19, 2018
@wookietreiber
Copy link
Contributor Author

BTW: workaround:

ansible all --list-hosts | awk 'NR > 1 { print $1 }'

@s-hertel s-hertel added inventory Inventory category and removed needs_triage Needs a first human triage before being processed. labels Apr 20, 2018
@utoddl
Copy link
Contributor

utoddl commented May 23, 2018

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.

@relrod
Copy link
Member

relrod commented Oct 30, 2020

As a workaround you can use a template to list hosts. We should extend ansible-inventory to support host patterns in the future to make this easier.

@nitzmahone nitzmahone added waiting_on_contributor This would be accepted but there are no plans to actively work on it. and removed affects_2.5 This issue/PR affects Ansible v2.5 labels Jun 22, 2022
@ansibot
Copy link
Contributor

ansibot commented Jun 26, 2023

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!

click here for bot help

@ansibot ansibot added bot_closed and removed waiting_on_contributor This would be accepted but there are no plans to actively work on it. labels Jun 26, 2023
@ansibot ansibot closed this as completed Jun 26, 2023
@ansible ansible locked and limited conversation to collaborators Jul 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.13 bot_closed feature This issue/PR relates to a feature request. has_pr This issue has an associated PR. inventory Inventory category support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants