如何在Ansible中使用lxc_容器模块?

2024-05-17 03:20:49 发布

您现在位置:Python中文网/ 问答频道 /正文

我在试着写这本剧本

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

目标主机是localhost,但它失败并显示以下错误

^{pr2}$

在这之后我试过了

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

Tags: installpipname错误witherrorrecordtmp
2条回答

如果尚未安装lxc-dev包,则可能会发生这种情况。目前,debian回购不包含它,您必须从第三方下载,如ubuntu

对于lxc_container-Ansible模块的正常操作,目标主机中不需要存在该dev包(lxc dev)或pip。目标主机和管理主机(运行Ansible的LXC容器模块文档)中列出的那些包中只需要python2。在

相关问题 更多 >