LXC error on Travis CI

Hello everyone,

I contribute to an open source project that leverages LXC for continuous integration on Travis CI.

Recently we’ve been facing an issue that we can’t seem to figure out a solution for - namely that our LXC tasks are failing when attempting to create a bridged network using the following command lxc create network testbr0 with the following error error: unknown command: network.

I have tried tried various approaches, for example explicitly running apt install lxd-client, but it’s a no-go as far as I can tell.

If anyone can point me in the right direction, I would be greatly appreciative of the help. If it helps, the last output from Travis can be found here.

Thank you all in advance.

Hi,

That has to do with the LXD version currently installed.

You are probably running LXD from the regular ubuntu repository which will install LXD 2.0.11.
I had a look on https://github.com/StreisandEffect/streisand/blob/master/tests/development-setup.yml, and I can give two suggestions to help you.

  1. Remove the following two tasks:
  • name: Install lxc ppa key
  • name: Install LXC ppa
    PPA Is no longer supported by the LXD team.
  1. Install LXD from xenial-backports:
- name: Install lxd
      apt:
        name: lxd
        state: latest
        default_release: xenial-backports

This should give you the latest LXD release with all the features including the lxc network feature.

I hope that this helps.

1 Like

Thank you so much, this is exactly what I needed to know!

Sadly this approach doesn’t seem to work, as travis-ci runs under Ubuntu 14.04; package installation fails on xenial-backports.

trusty-backports also uses the old version which is unaware of the network command.

Is there any other way of getting the latest lxd version on ubuntu 14.04?

Thanks again.

Sorry, I assumed it was 16.04.
To run the latest LXD on Ubuntu 14.04 I guess the easiest would be to install it via snapd.

https://insights.ubuntu.com/2017/03/30/snaps-are-now-available-for-ubuntu-14-04-lts-desktop-and-server/

Then you just need to install it with snap install lxd. AFAIK there is no ansible module to manage snap, so you need to install it with the shell or command module.

One of the caveats of using snap is that the binaries are under /snap/bin, so the commands are not available directly unless you call /snap/bin/lxc, so make sure to either call lxc that way or add /snap/bin your PATH env variable.

one approach that I use is to go ahead and install 2.0.11 on travis and then launch a nested xenial container, install the latest lxd in there, and then perform my testing in that subcontainer

Just came back for a follow up, the snap approach ended up working after a bit of fiddling around.
The end result can be seen here for those interested.

Thanks @Dnegreira for you help :slight_smile:

2 Likes

Hi,

I was passing by this link. I recently hit a problem when the Feature branch of LXD was removed from trusty. I use an ansible lxd role that I wrote to manage the install/configuration and deployments of my linux containers.

The feature branch have a lot to offer with the API, I already wrote an lxd_network module based on the lxd_profile one and I would certainly do the same for an lxd_storage one. (I have send a PR, but don’t have enough time to push it further.)

So without the possibility to use the Feature branch on travis, outside of snap, but I hade some trouble using it. I decided to add the possibility in my role to install an LTS version of LXD.

I use my lxd-role inside my other ansible role in order to test them with Travis. If it can help in any way, or interest someone, I leave it there :

lxd role : https://github.com/Nani-o/ansible-role-lxd
test template : https://github.com/Nani-o/ansible-template-role-test
how I use it : https://github.com/Nani-o/ansible-role-netdata/blob/master/.travis.yml
https://github.com/Nani-o/ansible-role-netdata/tree/master/tests

1 Like