2016-03-24 44 views
1

我試圖運行這個劇本如何在Ansible中使用lxc_container模塊?

--- 
- hosts: control 
    become: yes 
    tasks: 
    - name: Stop All Linux Containers 
     lxc_container: name={{ item }} state=started 
     with_items: 
     - app01 
     - app02 
     - lb01 
     - db01 

目標主機是本地主機,但它失敗並顯示以下錯誤

failed: [127.0.0.1] => (item=app01) => {"failed": true, "item": "app01", "parsed": false} 
BECOME-SUCCESS-rppgggxcewgndkgtnpptrgeglbfykput 
failed=True msg='The lxc module is not importable. Check the requirements.' 
The lxc module is not importable. Check the requirements 

這個我試過

pip install lxc-python2 

後(看到它從另一個stackoverflow帖子)但它也顯示一個錯誤

lxc.c:27:30: fatal error: lxc/lxccontainer.h: No such file or directory 

#include <lxc/lxccontainer.h> 

          ^

compilation terminated. 

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 

---------------------------------------- 
Cleaning up... 
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_dhruv/lxc-python2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-ZKdf9M-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_dhruv/lxc-python2 
Storing debug log for failure in /home/dhruv/.pip/pip.log 

回答

2

如果您尚未安裝lxc-dev軟件包,則可能會發生這種情況。目前它發生的事情是,debian回購沒有包含它,你必須從第三方下載,如ubuntu

+0

在這個問題上有同樣的錯誤,並且lxc-dev做了詭計!謝謝 – Deano

0

該開發包(lxc-dev)或pip不需要出現在目標主機中lxc_container -Ansible模塊正常運行。目標主機和管理主機中的LXC容器模塊文檔(您運行Ansible的文檔)中列出的軟件包中只需要存在python2。