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,420 points
411 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,850 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 5 hours ago in Ansible by MD
• 41,900 points
4 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,620 points
644 views
0 votes
1 answer
0 votes
1 answer

Role of subelement module in an Ansible playbook

Hey @Rahul thanks for a better question ...READ MORE

answered Jan 16, 2019 in Ansible by Emily
677 views
+13 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,420 points
601 views
0 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,850 points
1,869 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,850 points
9,755 views