我是ansible的新手,最近我遇到了一个新问题。我尝试运行攻略,下面是我得到的错误。
[bhar1@desktop ~]$ ansible-playbook -i inv abc.yaml -vvv
ansible-playbook 2.4.2.0
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/bhar1/.ansible/plugins /modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages /ansible
executable location = /bin/ansible-playbook
python version = 2.7.5 (default, Apr 11 2018, 07:36:10) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]
Using /etc/ansible/ansible.cfg as config file
[WARNING]: Unable to parse /home/bhar1/inv as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: Could not match supplied host pattern, ignoring: all
[WARNING]: provided hosts list is empty, only localhost is available
PLAYBOOK: abc.yaml **********************************************************************************************************************************
1 plays in abc.yaml
[WARNING]: Could not match supplied host pattern, ignoring: webservers
PLAY [webservers] ***********************************************************************************************************************************
skipping: no hosts matched
PLAY RECAP ******************************************************************************************************************************************
你能帮我解释一下为什么会这样吗?我的/etc/ansible/hosts文件是随着我们的webservers组的更新。下面是yml文件。
[bhar1@desktop ~]$ cat abc.yaml
---
- hosts: webservers
become: yes
tasks:
- name: remove httpd
yum:
name: httpd
state: absent
[bhar1@desktop ~]$
发布于 2019-04-10 14:38:19
如果您已经更新了/etc/ansible/hosts中的主机组,您需要使用-i传递路径,您传递了错误的文件,因为我看到它是空的,请使用下面的文件,看看它是否正常工作
ansible-playbook -i /etc/ansible/hosts abc.yaml
发布于 2019-09-13 15:45:31
显示错误是因为Ansible无法找到您的清单文件。
要执行剧本abc.yaml,请运行以下命令:
ansible-playbook -i /etc/ansible/hosts abc.yaml
执行告诉ansible使用/etc/ansible/hosts中可用的清单文件,并解析攻略文件"abc.yaml".Inventory参数-i用于传递清单路径。
发布于 2019-04-10 13:45:52
看起来ansible在寻找错误的清单文件。文件"/home/bhar1/inv“是否存在?如果不是,那么您应该使用:
ansible-playbook -i [/path/to/inventory_file] abc.yaml -vvv
https://stackoverflow.com/questions/55605354
复制相似问题