Using lxc container module in ansible

0 votes

I am using ansible and trying to execute this playbook

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

the target is a localhost but it fails and this error comes up:

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

Then I tried this:

pip install lxc-python2 

But this also shows error:

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
Aug 10, 2018 in Ansible by DragonLord999
• 8,450 points
564 views

1 answer to this question.

0 votes

This mostly happens when you've not installed lxc-dev package. In your situation it so happens that Debian Repository does not have it and you'll have to use it from third party like ubuntu.

answered Aug 10, 2018 by DareDev
• 6,890 points

Related Questions In Ansible

0 votes
1 answer

How to find the memory of remote systems using the setup module in Ansible?

Hi@akhtar, You need to use the setup module to ...READ MORE

answered Aug 10, 2020 in Ansible by MD
• 95,160 points
1,027 views
0 votes
1 answer

How to replace a line using lineinfile module in Ansible?

Hi@MD, You can use lineinfile module in Ansible. ...READ MORE

answered Sep 2, 2020 in Ansible by akhtar
• 38,170 points
566 views
0 votes
1 answer

Using hyphen in ansible

Hyphen - is used to specify list ...READ MORE

answered Jul 10, 2018 in Ansible by Kalgi
• 2,680 points
998 views
0 votes
1 answer
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
1,063 views
+2 votes
1 answer
0 votes
1 answer

Using multiple config files using same template in a role in ansible

Go through this include_role module: tasks: - ...READ MORE

answered Jun 5, 2018 in Ansible by DareDev
• 6,890 points
2,686 views
0 votes
1 answer

ansible playbook: using multiple variables in loops

Use an indexed hostname, and then define ...READ MORE

answered Jul 16, 2018 in Ansible by DareDev
• 6,890 points
13,105 views