Ansible Error : The lxc module is not importable. Check the requirements
Ansible Error : The lxc module is not importable. Check the requirements
我的任务看起来像这样
- 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
lxc_container 比较新。
要 运行 lxc_container 模块,您需要确保在目标主机上安装了 pip 包,以及 lxc。
例如
pip install lxc-python2
apt-get install lxc
我只是 运行 遇到了同样的问题,我通过确保在目标机器上 pip install lxc-python2
系统范围解决了它。
在我的例子中,目标是通过 ansible_connection=local
主机的本地主机,我认为我可以摆脱 pip: name=lxc-python2
,但它已安装到我当前的 virtualenv 中。
问题的正确答案是添加:
become: yes
就在 lxc_container
模块部分之前,以便获得目标主机上 运行 lxc-commands 的 root 权限。
绝对不需要安装任何 python2-lxc -support 库到 target 主机来使用 lxc_container 模块,这需要这样的支持仅在管理主机中可用。只有 python2 必须在目标主机中可用才能与当前 Ansible 版本一起使用。
有关 lxc-container module 要求的更多信息,请参阅 ansible 文档:(在执行模块的主机上)
- lxc >= 1.0 # OS 包
- python >= 2.6 # OS 包
- lxc-python2 >= 0.1 # 来自 https://github.com/lxc/python2-lxc
的 PIP 包
如果您使用 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
...
我的任务看起来像这样
- 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
lxc_container 比较新。 要 运行 lxc_container 模块,您需要确保在目标主机上安装了 pip 包,以及 lxc。
例如
pip install lxc-python2
apt-get install lxc
我只是 运行 遇到了同样的问题,我通过确保在目标机器上 pip install lxc-python2
系统范围解决了它。
在我的例子中,目标是通过 ansible_connection=local
主机的本地主机,我认为我可以摆脱 pip: name=lxc-python2
,但它已安装到我当前的 virtualenv 中。
问题的正确答案是添加:
become: yes
就在 lxc_container
模块部分之前,以便获得目标主机上 运行 lxc-commands 的 root 权限。
绝对不需要安装任何 python2-lxc -support 库到 target 主机来使用 lxc_container 模块,这需要这样的支持仅在管理主机中可用。只有 python2 必须在目标主机中可用才能与当前 Ansible 版本一起使用。
有关 lxc-container module 要求的更多信息,请参阅 ansible 文档:(在执行模块的主机上)
- lxc >= 1.0 # OS 包
- python >= 2.6 # OS 包
- lxc-python2 >= 0.1 # 来自 https://github.com/lxc/python2-lxc 的 PIP 包
如果您使用 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
...