作者:腾讯财经321 | 来源:互联网 | 2022-11-30 13:23
我是新手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
这是我第一次遇到此问题。
1> 小智..:
在运行剧本之前,只需运行以下命令
ansible all --list-hosts
如果以上错误仍然存在,请转到/etc/ansible/ansible.cfg
并编辑inventory
指向您的特定主机文件的路径。