[lxc-users] LXD configuration in Ansible

Sturm, Daniel dsturm at usgs.gov
Wed Oct 5 20:00:52 UTC 2016


Hi, I had a few questions about how LXD and the LXD_Command interface work
in Ansible.

Just some preface: We're implementing LXD and Ansible on
Ubuntu/Xenial/arm64 ODROID-C2 systems.

First, I've been using Stéphane Graber's website as a guide while setting
up LXD. The documentation for LXD appears to be incomplete, so I have been
using a lead designer's website as a guide. I have also been using this git
repository (https://github.com/lxc/lxd/blob/master/doc/configuration.md) as
a guide for my keys while configuring the profiles. I've noticed some of
them don't register.
'lxc profile set test nictype macvlan' gives me "error: Bad key: nictype",
and there doesn't appear to be a way to configure my gateway. I have four
variables that I had been using previously in LXC; lxc.network.type,
lxc.network.link, lxc.network.ipv4, lxc.network.ipv4.gateway. My assumption
is that the correct keys are respectively nictype, parent, ipv4.address,
and as I said, I'm not sure what to use for gateway.

In LXC, Snapshots created a copy-on-write filesystem which led to very
small containers. Is this feature still present in LXD?

In Ansible, I'd like to create snapshots with custom configurations of the
four variables I noted earlier (network type, network link, ipv4 address,
ipv4 gateway). Is there a way to template this in Ansible? Should I point
LXD at a correctly configured profile, or edit one later to match my
parameters? Here's my initial script, but I'd like to be sure I know what
the script will be doing before I commit to it:

- name: Create a started container
  lxd_container:
    name: template
    state: absent
    clone_snapshot: true
    clone_name: {{looping value}}
    source:
      type: image
      mode: pull
      server: https://images.linuxcontainers.org
      protocol: lxd
      alias: ubuntu/xenial/arm64
    profiles: ["{{looping value}}"]
    wait_for_ipv4_addresses: true
    timeout: 600

To clarify: the goal is to create a series of snapshots with corresponding
configs. I assume in this case that the "name:" is of the container the
snapshot is made from, state: absent implies that the snapshots cannot
repeat or replace existing ones, and that the source will make sure the
snapshots are using the correct operating system. If any of this is wrong,
I'd really appreciate knowing.

The only thing I don't see in the LXD ansible module are the snapshot
features. This was a feature I used the LXC_Command for, but the module
would not install properly on the systems I'm using for some reason, hence
the switch to LXD. (the error has something to do
with 'aarch64-linux-gnu-gcc' not existing while manually trying to set up
https://github.com/lxc/python2-lxc, no one I've asked has found a way to
solve this problem).




Thanks for any help you can give me,
-Daniel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20161005/d732331d/attachment.html>


More information about the lxc-users mailing list