2

我的任务看起来像这样

- name: Create a started container
    lxc_container:
      name: test-container-started
      container_log: true
      template: ubuntu
      state: started
      template_options: --release trusty

我收到以下错误:

> 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
4

4 回答 4

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
        ...
于 2016-10-12T21:26:20.993 回答
4

我刚刚遇到了同样的问题,我通过确保pip install lxc-python2目标机器上的系统范围来解决它。

在我的情况下,目标是通过ansible_connection=local主机的 localhost ,我认为我可以逃脱pip: name=lxc-python2,但安装到我当前的 virtualenv 中。

于 2015-08-21T17:17:45.860 回答
0

lxc_container 相对较新。要运行 lxc_container 模块,您需要确保在目标主机上安装了 pip 包以及 lxc。

例如

pip install lxc-python2
apt-get install lxc
于 2015-08-17T15:29:10.810 回答
-1

该问题的正确答案是 become: yes 在-module部分之前添加:lxc_container以便获得root权限以在目标主机上运行lxc-commands。

绝对不需要在目标主机上安装任何 python2-lxc -support 库以使用 lxc_container 模块,这需要仅在管理主机中提供此类支持。只有 python2 必须在目标主机中可用才能与当前的 Ansible 版本一起使用。

有关lxc-container 模块要求的更多信息,请参阅 ansible 文档 :(在执行模块的主机上)

于 2016-09-17T00:45:41.983 回答