ansible_hosts issue with 2.9.2

5,710 views
Skip to first unread message

Andrew Meyer

unread,
Jan 7, 2020, 2:14:31 PM1/7/20
to Ansible Project
Hello, I recently have installed ansible 2.9.2 from pip3 on CentOS 8.  Prior to that I was on whatever came from EPEL.

Right now I am having an issue no matter what playbook I run.  

This is my output on just about any playbook I run.

[andrew@jump01 playbooks]$ ansible-playbook deploy_grafana.yml -e 'target_servers=mon01.asm.example.com' -vvvvv
ansible-playbook 2.9.2
  config file = None
  configured module search path = ['/home/andrew/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/andrew/.local/lib/python3.6/site-packages/ansible
  executable location = /home/andrew/.local/bin/ansible-playbook
  python version = 3.6.8 (default, Oct  7 2019, 17:58:22) [GCC 8.2.1 20180905 (Red Hat 8.2.1-3)]
No config file found; using defaults
setting up inventory plugins
host_list declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
script declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
auto declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
yaml declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
ini declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
toml declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
[WARNING]: No inventory was parsed, only implicit localhost is available

[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

Loading callback plugin default of type stdout, v2.0 from /home/andrew/.local/lib/python3.6/site-packages/ansible/plugins/callback/default.py

PLAYBOOK: deploy_grafana.yml ****************************************************************************************************************************************************************************************************************
Positional arguments: deploy_grafana.yml
verbosity: 5
connection: smart
timeout: 10
become_method: sudo
tags: ('all',)
inventory: ('/etc/ansible/hosts',)
extra_vars: ('target_servers=mon01.asm.example.com',)
forks: 5
1 plays in deploy_grafana.yml
[WARNING]: Could not match supplied host pattern, ignoring: mon01.asm.example.com


PLAY [mon01.asm.example.com] **************************************************************************************************************************************************************************************************************
skipping: no hosts matched

PLAY RECAP **********************************************************************************************************************************************************************************************************************************

[andrew@jump01 playbooks]$

I have verified with ansible-config that the config is showing up.

[andrew@jump01 playbooks]$ ansible-config dump -c ../ansible.cfg |grep -i hosts
DEFAULT_HOST_LIST(/home/andrew/automation/ansible/ansible.cfg) = ['/home/andrew/automation/ansible/hosts/ansible_hosts']
DISPLAY_SKIPPED_HOSTS(default) = True
[andrew@jump01 playbooks]$


Should I file a bug?

The ansible.cfg is in my ~/automation/ansible/

Kai Stian Olstad

unread,
Jan 7, 2020, 2:59:39 PM1/7/20
to ansible...@googlegroups.com
On 07.01.2020 20:14, Andrew Meyer wrote:
> [andrew@jump01 playbooks]$ ansible-playbook deploy_grafana.yml -e
> 'target_servers=mon01.asm.example.com' -vvvvv
> ansible-playbook 2.9.2
> config file = None

So it doesn't find any config file aka ansible.cfg

> configured module search path = ['/home/andrew/.ansible/plugins/modules',
> '/usr/share/ansible/plugins/modules']
> ansible python module location =
> /home/andrew/.local/lib/python3.6/site-packages/ansible
> executable location = /home/andrew/.local/bin/ansible-playbook
> python version = 3.6.8 (default, Oct 7 2019, 17:58:22) [GCC 8.2.1
> 20180905 (Red Hat 8.2.1-3)]
> No config file found; using defaults

so default configuration is used.


> I have verified with ansible-config that the config is showing up.
>
> [andrew@jump01 playbooks]$ ansible-config dump -c ../ansible.cfg |grep -i

If show because you say where it is with -c
But ansible-playbook doesn't know that.


> hosts
> DEFAULT_HOST_LIST(/home/andrew/automation/ansible/ansible.cfg) =
> ['/home/andrew/automation/ansible/hosts/ansible_hosts']
> DISPLAY_SKIPPED_HOSTS(default) = True
> [andrew@jump01 playbooks]$
>
>
> Should I file a bug?
>
> The ansible.cfg is in my ~/automation/ansible/

But you are in a different directory that ansible.cfg.
ansible is only looking in four places an use the first one it finds.

https://docs.ansible.com/ansible/latest/reference_appendices/config.html#ansible-configuration-settings-locations

- ANSIBLE_CONFIG (environment variable if set)
- ansible.cfg (in the current directory)
- ~/.ansible.cfg (in the home directory)
- /etc/ansible/ansible.cfg

So you need to adjust accordingly.


--
Kai Stian Olstad
Reply all
Reply to author
Forward
0 new messages