头先计划-ansible

头先计划-ansible,ansible,Ansible,我使用以下命令安装了ansible sudo apt-add-repository ppa:ansible/ansible sudo apt update sudo apt install ansible 我跟着这个。通过使用它,我创建了一个名为test.yml的yml文件(代码如下所示) 然后我运行ansible playbook./test.yml。我得到以下错误 我不知道我错过了什么。任何想法都值得赞赏。非常感谢你 sato:~/play_around_with_ansible$ ans

我使用以下命令安装了ansible

sudo apt-add-repository ppa:ansible/ansible
sudo apt update
sudo apt install ansible
我跟着这个。通过使用它,我创建了一个名为test.yml的yml文件(代码如下所示)

然后我运行
ansible playbook./test.yml
。我得到以下错误

我不知道我错过了什么。任何想法都值得赞赏。非常感谢你

sato:~/play_around_with_ansible$ ansible-playbook ./test.yml
 [WARNING]: provided hosts list is empty, only localhost is available. Note
that the implicit localhost does not match 'all'

ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.

The error appears to be in '/home/ven/play_around_with_ansible/test.yml': line 4, column 5, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  tasks:
  - name: run the new module
    ^ here

您缺少库存文件。在当前文件夹或您选择的目录中创建资源清册文件,并提供ansible playbook命令的资源清册文件路径,如下所示,或者您可以在ansible.cfg中提及主机文件的默认位置

库存文件内容(样本)

命令

ansible-playbook -i inventory ./test.yml

在上面的命令中,
inventory
是带有路径的文件名。

您的“yaml”文件似乎无法识别自定义模块的路径。甚至我对定制模块开发都是新手。根据标准,您应该将.py文件保存在“library”目录中,并在library目录之外创建.ymal文件


这将帮助您的yaml文件在./library目录中查找模块。

我已经这样做了,但出现以下错误。任何想法都欢迎。非常感谢。
[127.0.1]
localhost ansible_connection=local
ansible-playbook -i inventory ./test.yml