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

add --list-hosts-plain for list of hosts suitable for pipes / scripts #40624

Open
wants to merge 2 commits into
base: devel
from

Conversation

Projects
None yet
4 participants
@utoddl

utoddl commented May 23, 2018

SUMMARY

Output from --list-hosts contains spurious information (number of hosts, extra white space) which makes it less easily consumed by scripts. The addition of a --list-hosts-plain option omits this extra text.

Fixes #39003

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

cli

ANSIBLE VERSION
ansible 2.6.0dev0 (listhosts bed58a0fa9) last updated 2018/05/23 12:32:29 (GMT -400)
  config file = /home/utoddl/.ansible.cfg
  configured module search path = [u'/home/utoddl/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/utoddl/src/ansible/lib/ansible
  executable location = /home/utoddl/src/ansible/bin/ansible
  python version = 2.7.15 (default, May 16 2018, 17:50:09) [GCC 8.1.1 20180502 (Red Hat 8.1.1-1)]
ADDITIONAL INFORMATION

In the Ansible on RHEL prior to version 2, this extra "Hosts (#):" line was not produced. Upgrading our Ansible broke many of our automation scripts which used "ansible --list-hosts" to get lists of hosts.

Before:

$ ./bin/ansible www\* --list-hosts
  hosts (7):
    wwwdot1t.isis.unc.edu
    wwwdot2p.isis.unc.edu
    wwwdot0p.isis.unc.edu
    wwwdot3p.isis.unc.edu
    wwwdot1p.isis.unc.edu
    wwwdot0f.isis.unc.edu
    wwwdot0t.isis.unc.edu

After:

$ ./bin/ansible www\* --list-hosts-plain
wwwdot1t.isis.unc.edu
wwwdot2p.isis.unc.edu
wwwdot0p.isis.unc.edu
wwwdot3p.isis.unc.edu
wwwdot1p.isis.unc.edu
wwwdot0f.isis.unc.edu
wwwdot0t.isis.unc.edu
@bcoca

This comment has been minimized.

Member

bcoca commented May 23, 2018

im looking at #38403 as a more generic fix and it avoids new cli options.

@bcoca bcoca removed the needs_triage label May 23, 2018

@bcoca bcoca changed the title from Fixes #39003, add --list-hosts-plain for list of hosts suitable for pipes / scripts to add --list-hosts-plain for list of hosts suitable for pipes / scripts May 23, 2018

@mattclay

This comment has been minimized.

Member

mattclay commented May 24, 2018

The sanity test failures are valid. The integration test failure is unrelated. The bot should comment on the sanity test failures soon.

@ansibot

This comment has been minimized.

Contributor

ansibot commented May 24, 2018

The test ansible-test sanity --test pylint [explain] failed with 5 errors:

lib/ansible/cli/__init__.py:421:0: unnecessary-semicolon Unnecessary semicolon
lib/ansible/cli/__init__.py:423:0: unnecessary-semicolon Unnecessary semicolon
lib/ansible/cli/__init__.py:425:0: unnecessary-semicolon Unnecessary semicolon
lib/ansible/cli/adhoc.py:126:0: unnecessary-semicolon Unnecessary semicolon
lib/ansible/cli/adhoc.py:129:0: unnecessary-semicolon Unnecessary semicolon

The test ansible-test sanity --test pep8 [explain] failed with 6 errors:

lib/ansible/cli/__init__.py:421:39: E703 statement ends with a semicolon
lib/ansible/cli/__init__.py:423:48: E703 statement ends with a semicolon
lib/ansible/cli/__init__.py:425:49: E703 statement ends with a semicolon
lib/ansible/cli/adhoc.py:126:24: E703 statement ends with a semicolon
lib/ansible/cli/adhoc.py:129:32: E703 statement ends with a semicolon
lib/ansible/cli/adhoc.py:131:49: E231 missing whitespace after ','

click here for bot help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment