lae / ansible-role-travis-lxc

Ansible role that prepares a Travis CI environment and creates LXC containers for testing roles.
MIT License
4 stars 2 forks source link

Add support for Fedora #13

Closed lae closed 6 years ago

lae commented 6 years ago

This should probably be simple enough. Tasks for current stable Fedora releases should be added under tasks/ and tests should be included within .travis.yml, probably similar to the CentOS ones.

wilmardo commented 6 years ago

Started with this but it seems the Fedora containers start without an eth0 interface only a localhost interface is listed. See the Centos 7 output (link) vs. the Fedora 26 output (link). Do you have any knowledge on how to fix this?

lae commented 6 years ago

Fedora LXC template is here (direct link is to usage) https://github.com/lxc/lxc/blob/master/templates/lxc-fedora.in#L932

Off the top of my head, I don't know. Quick google search didn't help either. To debug this, I'd bring up a Ubuntu 14 host somewhere, install the LXC PPA and packages, and then try to debug creating/starting the LXC container manually (and I guess also look through the template more thoroughly).

Weird that it's happening on all the Fedora containers.

wilmardo commented 6 years ago

Found that template indeed and the options seem the same as the Centos template, that is what makes this extra weird. Hopefully this weekend I will spinup a Ubuntu 14.04 instance on my local server and debug some more. Keep you posted!

lae commented 6 years ago

Actually brought up an instance about an hour ago to test but got sidetracked.

I found that adding the following (well, uncommenting) to the LXC container config prior to starting the container brought up an eth0 interface:

lxc.net.0.type = veth
lxc.net.0.flags = up
lxc.net.0.link = lxcbr0
lxc.net.0.name = eth0

It seems that the Fedora template doesn't do this, but the CentOS one (and I assume the others that we already support) do. The CentOS one actually omits lxc.net.0.name though and specifies a hwaddr:

lxc.net.0.type = veth
lxc.net.0.link = lxcbr0
lxc.net.0.hwaddr = fe:eb:f9:82:e0:51
lxc.net.0.flags = up

I assume that only type, link and flags are required to enable an eth0 interface within the container itself. I guess to resolve this, we should specify those within the container_config parameter that's passed to the lxc_container module. Rather than having this be limited to Fedora, it probably makes sense to have that config specified across all templates (the lxc_container module should remove duplicate entries iirc).

I think having an internal var for an lxc "network config" that then gets merged into the container_config var using the set_fact module in tasks/main would be good?