Ansible connection plugin using ssh + lxc-attach
Branch: master
Clone or download
Latest commit 0cda450 Feb 16, 2016
Type Name Latest commit message Commit time
Failed to load latest commit information. Add file Feb 16, 2016 Initial version, plugin for ansible 2.0 Feb 16, 2016


Ansible connection plugin using ssh + lxc-attach


This plugin allows to use Ansible on a remote server hosting LXC containers, without having to install SSH servers in each LXC container.

The plugin connects to the host using SSH, then uses lxc-attach to enter the container. This means the SSH connection must login as root, otherwise lxc-attach will fail.


Add to ansible.cfg:

connection_plugins = /path/to/connection_plugins/lxc_ssh

Then, modify your hosts file to use the lxc_ssh transport:

container ansible_host=server ansible_connection=lxc_ssh ansible_ssh_extra_args=container


  • I haven't found any proper method to access the 'inventory_name' from the connection plugin, so I used 'ansible_ssh_extra_args' to store the name of the container.