![运行 lxd_container 模块的示例时,Ansible 返回“任务中未检测到任何操作”](https://linux22.com/image/706337/%E8%BF%90%E8%A1%8C%20lxd_container%20%E6%A8%A1%E5%9D%97%E7%9A%84%E7%A4%BA%E4%BE%8B%E6%97%B6%EF%BC%8CAnsible%20%E8%BF%94%E5%9B%9E%E2%80%9C%E4%BB%BB%E5%8A%A1%E4%B8%AD%E6%9C%AA%E6%A3%80%E6%B5%8B%E5%88%B0%E4%BB%BB%E4%BD%95%E6%93%8D%E4%BD%9C%E2%80%9D.png)
我使用了以下页面https://docs.ansible.com/ansible/lxd_container_module.html提取以下 lxd 示例并将其放入 YAML 文件中:
>>> cat play.yaml
---
# An example for creating a Ubuntu container and install python
- hosts: localhost
connection: local
tasks:
- name: Create a started container
lxd_container:
name: mycontainer
state: started
source:
type: image
mode: pull
server: https://images.linuxcontainers.org
protocol: lxd
alias: ubuntu/xenial/amd64
profiles: ["default"]
wait_for_ipv4_addresses: true
timeout: 600
但是运行它时我收到以下错误:
>>> ansible-playbook play.yaml
ERROR! no action detected in task
The error appears to have been in '/root/play': line 6, column 7, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
tasks:
- name: Create a started container
^ here
YAML 文件的格式看起来正确。我也检查了,ansible-doc -l | grep "lxd"
但没有返回任何结果。
什么原因导致任务无法运行?
答案1
lxd_container模块是在 Ansible 版本 2.2 中添加的。使用以下命令检查您的 Ansible 版本,ansible --version
并根据需要使用以下命令更新您的 Ansible 安装:pip install ansible --upgrade