please help: how does the lxc connection plugin work?

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 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):


# 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:


$ 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!

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.