我使用了以下页面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