Anybody working on ansible modules for lxd?

655 views
Skip to first unread message

candlerb

unread,
May 15, 2016, 4:29:27 AM5/15/16
to Ansible Project
lxd is the new container system which is included by default in ubuntu 16.04:

Unlike docker, lxd containers are essentially lightweight VMs, with their own init daemon, sshd etc, and typically on a static IP address.

I'd like an ansible to:

(1) Handle lifecycle management: create/configure, start and stop lxd containers; install lxd profiles.

(2) Be able to execute commands within a container using "lxc exec <container> <command>" - so you don't have to set up an ssh trust relationship with the container. Something like "ansible_connection=lxd" in the inventory.

This could be done by shelling out to the "lxc xxx" commands (confusingly prefixed lxc not lxd). Alternatively, lxd also has a proper API you can talk to, with a python client too.

Using the CLI you can control remote hosts using "<host>:<instance>" as the container name. Using the REST API you connect directly to the host of interest.

Is there any work going on in this area? All I've been able to find is an ansible module for installing lxd itself on your host platform.

Thanks,

Brian.

Kai Stian Olstad

unread,
May 15, 2016, 5:12:14 AM5/15/16
to ansible...@googlegroups.com
On 15. May 2016 10:29, candlerb wrote:
> Is there any work going on in this area? All I've been able to find is an
> ansible module for installing lxd itself on your host platform.

On the developer list Hiroaki Nakamura posted this on May 10:

<quote>
I created the lxd_container Ansible module and sent a pull request to
the ansible-modules-extra project.

"Add lxd_container module by hnakamur · Pull Request #2208 ·
ansible/ansible-modules-extras"
https://github.com/ansible/ansible-modules-extras/pull/2208

Could you take a look at the pull request and send me a feedback?
Any feedbacks are welcome.
</quote>

--
Kai Stian Olstad

candlerb

unread,
May 15, 2016, 8:32:57 AM5/15/16
to Ansible Project, ansible-pr...@olstad.com
I don't have time to actually test it today.

Looking at the code/features: this looks like a good starting point. It is missing the ability to create or update a profile (idempotently) which is something I'll need.

A separate desirable feature would be "ansible_connection=lxd", using:

but I don't know if that can be done in a module, or needs to be in the core.

Anyway, I'll try out the module as it is, as soon as I get a chance.

Regards,

Brian.

Matt Martz

unread,
May 15, 2016, 10:13:28 AM5/15/16
to ansible...@googlegroups.com, ansible-pr...@olstad.com
An lxd connection plugin will be included in Ansible 2.1 which just had an RC2 release a few days ago.
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/510bf904-a299-4e7e-bd75-fa39e1290619%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Matt Martz
@sivel
sivel.net

candlerb

unread,
May 17, 2016, 5:39:15 AM5/17/16
to Ansible Project, ansible-pr...@olstad.com
So it should already be usable in ansible 2.2.0 devel? Super.

Yep, just tested it. Thank you!!

will

unread,
Oct 10, 2016, 2:03:51 PM10/10/16
to Ansible Project
There is also a dynamic inventory script build on the REST api here on GitHub: https://github.com/june07/Ansible-LXDynamic-Inventory
Reply all
Reply to author
Forward
0 new messages