我是ansible
的新手,得到了以下问题。我能够ssh到我的客户端机器。但无法运行playbook。
得到以下错误:
[WARNING]: Unable to parse /etc/ansible/hosts as an inventory source
[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'
[WARNING]: Could not match supplied host pattern, ignoring: a
这是一个我的团体名称。我的主人在下面给出:
---------
[a]
172.31.26.93
[all:vars]
ansible_user=vagrant
ansible_ssh_pass=vagrant
ansible_ssh_host=172.31.26.93
ansible_ssh_port=22
ansible_ssh_user='ansibleuser'
ansible_ssh_private_key_file=/home/ansibleuser/.ssh
-------我的剧本文件如下----
- hosts: a
tasks:
- name: create a directory
file: path=/home/ansiblesuser/www state=directory
这是我第一次遇到这个问题。
在运行playbook之前,只需运行以下命令
ansible all --list-hosts
如果上述错误仍然存在,请转到/etc/ansible/ansible.cfg
并编辑指向特定主机文件的inventory
路径。
以下为我解决了这个问题:
/
cd etc
或mkdir etc
和cd etc
mkdir ansible
然后cd ansible
vi hosts
(然后添加主机)chmod 777 hosts
。ansible all -m ping