我使用了以下页面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-doc -l | grep "lxd"然而没有结果被返回。
什么导致任务不运行?
在Ansible 2.2版本中添加了lxd_container模块。 用ansible ansible --version检查你的Ansible版本,如果需要用pip install ansible --upgrade ansible –upgrade更新你的Ansible安装