Ansible 错误:lxc 模块不可导入。检查要求

Nis*_*ngh 2 ansible devops

我的任务看起来像这样

- name: Create a started container
    lxc_container:
      name: test-container-started
      container_log: true
      template: ubuntu
      state: started
      template_options: --release trusty
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

> TASK: [lxc | Create a started container]
> **************************************  failed: [localhost] => {"failed": true, "parsed": false}
> BECOME-SUCCESS-azsyqtknxvlowmknianyqnmdhuggnanw failed=True msg='The
> lxc module is not importable. Check the requirements.' The lxc module
> is not importable. Check the requirements.
> 
> 
> FATAL: all hosts have already failed -- aborting
Run Code Online (Sandbox Code Playgroud)

ger*_*tas 5

如果您使用 Debian 或 Ubuntu 作为主机系统,则已经有python-lxc可用的软件包。安装它的最佳方法当然是 Ansible,就在lxc_container任务之前:

  tasks:

    - name: Install provisioning dependencies
      apt: name=python-lxc

    - name: Create docker1.lxc container
      lxc_container:
        name: docker1
        ...
Run Code Online (Sandbox Code Playgroud)