我是ansible
的新手,遇到了以下问题。
我可以ssh进入客户端计算机。但是无法运行剧本。
得到以下错误:
[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
这是我第一次遇到此问题。
最佳答案
在运行剧本之前,只需运行以下命令
ansible all --list-hosts
如果以上错误仍然存在,请转到
/etc/ansible/ansible.cfg
并编辑指向您的特定主机文件的inventory
路径。关于ssh - Ansible :Unable to parse/etc/ansible/hosts as an inventory source,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53205687/