# please help: how does the lxc connection plugin work?

**URL:** <https://forum.ansible.com/t/please-help-how-does-the-lxc-connection-plugin-work/28626>\
**Category:** Ansible Project\
**Created:** [September 21, 2018, 12:48pm UTC](https://forum.ansible.com/t/please-help-how-does-the-lxc-connection-plugin-work/28626 "2018-09-21T12:48:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![olapodrido](https://avatars.discourse-cdn.com/v4/letter/o/50afbb/32.png) [@olapodrido](https://forum.ansible.com/u/olapodrido)\
**Post date:** [September 21, 2018, 12:48pm UTC](https://forum.ansible.com/t/please-help-how-does-the-lxc-connection-plugin-work/28626/1 "2018-09-21T12:48:20Z")

</div>

Hi!

Apologies: I am a relatively new with Ansible.

Ansible controls several hosts which run LXC containers (no LXD involvement). I can install these containers just fine. But how do I configure them internally, like installing programs, creating user accounts and so on?

I had the impression that I could use [an LXC connection plugin](https://docs.ansible.com/ansible/2.5/plugins/connection/lxc.html) for that, but documentation is sparse. Is it broken or am I doing it wrong?

For example, host `osdev-01` is an LXC server, running a container `FS-dev`. How could I connect and Ansible-ping this container?

I have tried these definitions in the inventory/hosts file (of course I tried them one at a time):

```auto

# LXC server. Working, fully functioning connection
osdev-01 ansible_host=<ip address>

# several LXC container definitions
FS-dev ansible_connection=lxc ansible_host=osdev-01
FS-dev ansible_connection=lxc ansible_lxc_host=osdev-01
FS-dev ansible_connection=lxc ansible_lxc_host=osdev-01 ansible_host=FS-dev
FS-dev ansible_connection=lxc ansible_host=<ip address of osdev-01>

```

The result is always the same:

```auto

$ ansible FS-dev -m ping -vvvv
ansible 2.6.4
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/usr/local/lib/python2.7/dist-packages/ara/plugins/modules']
  ansible python module location = /usr/local/lib/python2.7/dist-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 2.7.15rc1 (default, Apr 15 2018, 21:51:34) [GCC 7.3.0]
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
Parsed /opt/ansible/inventory/hosts inventory source with ini plugin
Loading callback plugin minimal of type stdout, v2.0 from /usr/local/lib/python2.7/dist-packages/ansible/plugins/callback/minimal.pyc
META: ran handlers
Using module file /usr/local/lib/python2.7/dist-packages/ansible/modules/system/ping.py
<os-dev01> THIS IS A LOCAL LXC DIR
FS-dev | FAILED! => {
    "msg": "osdev-01 is not running"
}

```

Ansible evidently does not connect to the LXC server osdev-01. It seems that the target host definition is ignored (or the connection is misconfigured).

Huge thanks to anybody able to educate me!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [December 11, 2018, 7:00pm UTC](https://forum.ansible.com/t/please-help-how-does-the-lxc-connection-plugin-work/28626/2 "2018-12-11T19:00:53Z")

</div>

ansible\_host should be the container, but lxc is designed to execute  
on the lxc host server, so you need to install ansible on that and use  
it as controller.
