我使用以下页面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"
但是没有返回结果。
是什么导致任务无法运行?
在 Ansible 2.2 版中添加了lxd_container模块。检查您的 Ansible 版本,
ansible --version
并在需要时更新您的 Ansible 安装pip install ansible --upgrade