Skip to content

Commit

Permalink
Cleanup the host prep role & remove redundant tasks
Browse files Browse the repository at this point in the history
The LXC-Container-Create role now has the ability to setup all of the
network interfaces using systemd-networkd. Those changes give us a
uniform interface to consume when we create containers and free's the
roles from having to care about specific container interface config.
This change removes our now redundant tasks.

This also ensures "dbus" is available in the base contianer image
which was simply added for consistency.

Change-Id: I9278b1f73e1e0fdf98ab5fbe016a77aeb3f75be2
Depends-On: I5d3ddcfa11d575648a69a04f2fb30236c2c89da3
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
  • Loading branch information
cloudnull committed Feb 28, 2018
1 parent dbaab47 commit bf14315
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 46 deletions.
5 changes: 0 additions & 5 deletions defaults/main.yml
Expand Up @@ -86,11 +86,6 @@ lxc_net6_address: null ## ie. fd05:ffb8:32b4:1212::1
lxc_net6_netmask: null ## ie. 64
lxc_net6_nat: false

# lxc_container_net_link variable should be set to the lxc-net bridge.
lxc_container_net_link: "{{ lxc_net_bridge }}" ## name of the host bridge to attach to
lxc_container_net_type: veth ## lxc network interface type (veth, phys, vlan, macvlan, empty)
lxc_container_net_name: eth0 ## name of the interface inside the container.

# System control kernel tuning
lxc_kernel_options:
- { key: 'fs.inotify.max_user_instances', value: 1024 }
Expand Down
1 change: 0 additions & 1 deletion tasks/lxc_post_install.yml
Expand Up @@ -32,7 +32,6 @@
mode: "{{ item.mode|default('0644') }}"
with_items:
- { src: lxc-openstack.conf.j2, dest: "/etc/lxc/lxc-openstack.conf" }
- { src: default.conf.j2, dest: "/etc/lxc/default.conf" }
- { src: lxc.default.j2, dest: "{{ system_config_dir}}/lxc-net", mode: "0644" }
- { src: lxc-system-manage.j2, dest: "/usr/local/bin/lxc-system-manage", mode: "0755" }
tags:
Expand Down
5 changes: 0 additions & 5 deletions templates/default.conf.j2

This file was deleted.

10 changes: 0 additions & 10 deletions templates/lxc-openstack.conf.j2
Expand Up @@ -4,13 +4,3 @@ lxc.start.auto = 1
lxc.start.delay = 15
lxc.group = onboot
lxc.group = openstack

# Default LXC network
lxc.network.type = {{ lxc_container_net_type }}
lxc.network.name = {{ lxc_container_net_name }}
lxc.network.link = {{ lxc_container_net_link }}
lxc.network.flags = up
{% if lxc_net_mtu is defined %}
lxc.network.mtu = {{ lxc_net_mtu }}
{% endif %}
lxc.network.hwaddr = 00:16:3e:xx:xx:xx
11 changes: 3 additions & 8 deletions vars/redhat-7.yml
Expand Up @@ -80,15 +80,16 @@ lxc_cache_map:
ln -s /usr/bin/python2.7 /usr/bin/python
rm /etc/machine-id || true
rm /var/lib/dbus/machine-id || true
touch /etc/machine-id
yum clean all
mkdir -p /var/backup
echo -e '{{ lxc_container_default_interfaces }}' | tee /etc/sysconfig/network-scripts/ifcfg-eth0
chage -I -1 -d -1 -m 0 -M 99999 -E -1 root
if [ -a /etc/resolv.conf.org ]; then
mv /etc/resolv.conf.org /etc/resolv.conf
else
rm -f /etc/resolv.conf
fi
systemctl enable systemd-networkd
{{ lxc_cache_prep_post_commands }}
_lxc_cache_distro_packages:
Expand All @@ -104,6 +105,7 @@ _lxc_cache_distro_packages:
- python-devel
- rsync
- sudo
- systemd-networkd
- tar
- wget
- which
Expand All @@ -118,10 +120,3 @@ lxc_cached_network_interfaces:
dest: "/etc/sysconfig/network-scripts/ifdown-post-{{ lxc_net_bridge }}"
mode: "0755"
interface: "${DEVICE}"

lxc_container_default_interfaces: |
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
NM_CONTROLLED=no
TYPE=Ethernet
18 changes: 13 additions & 5 deletions vars/suse-42.yml
Expand Up @@ -29,6 +29,7 @@ lxc_hosts_distro_packages:
- aria2
- bridge-utils
- btrfsprogs
- dbus-1
- dnsmasq
- git-core
- libseccomp2
Expand Down Expand Up @@ -68,7 +69,6 @@ lxc_cache_map:
zypper --gpg-auto-import-keys -n dup --force-resolution -l
zypper --gpg-auto-import-keys -n in --force-resolution -l {{ lxc_cache_distro_packages | join(' ') }}
mkdir -p /var/backup
echo -e '{{ lxc_container_default_interfaces }}' | tee /etc/sysconfig/network/ifcfg-eth0
chage -I -1 -d -1 -m 0 -M 99999 -E -1 root
if [ -a /etc/resolv.conf.org ]; then
mv /etc/resolv.conf.org /etc/resolv.conf
Expand All @@ -79,6 +79,18 @@ lxc_cache_map:
# https://github.com/lxc/lxc-ci/commit/8dc7105399350a59698538a12b6d5a1a880ef2ba
systemctl -q unmask sshd
systemctl -q enable sshd
rm /etc/machine-id || true
rm /var/lib/dbus/machine-id || true
touch /etc/machine-id
for action in disable mask; do
systemctl ${action} wicked.service || true
systemctl ${action} wickedd.service || true
systemctl ${action} wickedd-auto4.service || true
systemctl ${action} wickedd-dhcp4.service || true
systemctl ${action} wickedd-dhcp6.service || true
systemctl ${action} wickedd-nanny.service || true
done
systemctl enable systemd-networkd
{{ lxc_cache_prep_post_commands }}
_lxc_cache_distro_packages:
Expand Down Expand Up @@ -106,7 +118,3 @@ lxc_cached_network_interfaces:
dest: "/etc/sysconfig/network/scripts/ifdown-post-{{ lxc_net_bridge }}"
mode: "0755"
interface: "${1}"

lxc_container_default_interfaces: |
STARTMODE=auto
BOOTPROTO=dhcp
21 changes: 9 additions & 12 deletions vars/ubuntu-16.04.yml
Expand Up @@ -73,7 +73,7 @@ lxc_cache_map:
apt-key add /root/repo.keys
rm /root/repo.keys
export DEBIAN_FRONTEND=noninteractive
apt-get remove -y --purge snap* lxc* lxd* || true
apt-get remove -y --purge snap* lxc* lxd* resolvconf* || true
# Update base distribution
apt-get update
apt-get upgrade -y
Expand All @@ -82,20 +82,26 @@ lxc_cache_map:
rm -f /usr/bin/python
rm /etc/machine-id || true
rm /var/lib/dbus/machine-id || true
touch /etc/machine-id
ln -s /usr/bin/python2.7 /usr/bin/python
mkdir -p /root/.ssh
chmod 700 /root/.ssh
userdel --force --remove ubuntu || true
apt-get clean
mkdir -p /var/backup
echo -e '{{ lxc_container_default_interfaces }}' | tee /etc/network/interfaces
mkdir -p /etc/network/interfaces.d
chage -I -1 -d -1 -m 0 -M 99999 -E -1 root
if [ -a /etc/resolv.conf.org ]; then
mv /etc/resolv.conf.org /etc/resolv.conf
else
rm -f /etc/resolv.conf
fi
for action in disable mask; do
systemctl ${action} resolvconf.service || true
systemctl ${action} systemd-networkd-resolvconf-update.path || true
systemctl ${action} systemd-networkd-resolvconf-update.service || true
done
systemctl enable systemd-networkd
{{ lxc_cache_prep_post_commands }}
# This forces any modified configurations to remain, and any unmodified configs to be replaced
Expand All @@ -106,6 +112,7 @@ _lxc_cache_distro_packages:
- apt-transport-https
- ca-certificates
- cron # xenial doesn't have cronie
- dbus
- gcc
- libffi-dev
- libssl-dev
Expand All @@ -123,13 +130,3 @@ _lxc_cache_distro_packages:
lxc_cached_network_interfaces:
- src: "lxc-net-bridge.cfg.j2"
dest: "/etc/network/interfaces.d/lxc-net-bridge.cfg"

lxc_container_default_interfaces: |
# The loopback network interface
auto lo
iface lo inet loopback
# LXC interface, this is ALWAYS assumed to be DHCP.
auto eth0
iface eth0 inet dhcp
# Load any additional configs
source /etc/network/interfaces.d/*.cfg

0 comments on commit bf14315

Please sign in to comment.