Ansible:无法将/etc/ansible/hosts 解析为清单源 [英] Ansible :Unable to parse /etc/ansible/hosts as an inventory source
本文介绍了Ansible:无法将/etc/ansible/hosts 解析为清单源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是 ansible
的新手,遇到了以下问题.我能够通过 ssh 连接到我的客户端机器.但无法运行 playbook.
I am new to ansible
, got the below issue.
I was able to ssh into my client machine .but unable to run 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 是我的组名.我的主机如下:
here a is my group name. my hosts given below :
---------
[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
-------我的剧本文件如下----
------- my playbook file given below ----
- hosts: a
tasks:
- name: create a directory
file: path=/home/ansiblesuser/www state=directory
这是我第一次遇到这个问题.
This is the first time I am getting this issue.
推荐答案
在运行 playbook 之前只需运行以下命令
Before running the playbook just run the following command
ansible all --list-hosts
如果上述错误仍然存在,请转到 /etc/ansible/ansible.cfg
并编辑指向您的特定主机文件的 inventory
路径.
If the above error persists then go to /etc/ansible/ansible.cfg
and edit the inventory
path which points to your specific host file.
这篇关于Ansible:无法将/etc/ansible/hosts 解析为清单源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文