我对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 ~]$
答案 0 :(得分:1)
如果您已更新/ etc / ansible / hosts中的主机组,则需要使用-i传递路径,因为我看到的文件为空,所以传递了错误的文件,请在下面使用并查看其是否有效
ansible-playbook -i /etc/ansible/hosts abc.yaml
答案 1 :(得分:1)
显示错误,因为Ansible无法找到您的库存文件。
要执行剧本abc.yaml,请运行以下命令:
mode: 'production'
执行告诉ansible使用/ etc / ansible / hosts中可用的清单文件并解析剧本文件“ abc.yaml”。清单参数-i用于传递清单路径。
答案 2 :(得分:0)
似乎很可能在寻找错误的库存文件。 这个文件“ / home / bhar1 / inv”是否存在? 如果没有,那么您应该使用:
compileSdkVersion 28
buildToolsVersion "28.0.3