Dave Wilde 28cdc6e72e Update MNAIO to deploy systemd-networkd
With bionic we need to switch to systemd-networkd rather
than the legacy /e/n/i.  This makes the mnaio host networkd only,
since we will only be supprting xenial and beyond on the host we
can do this.  The VM's will detect the networking configuration
daemon and act appropriately.  This also brings up the IPs on
the bridges without having any interfaces attached.

Change-Id: I72283a2786316181f7ab7d8aad21ad456e9c9503
2018-10-11 16:35:48 -05:00

31 lines
1.2 KiB
Django/Jinja

#!/usr/bin/env bash
wget --no-proxy http://{{ tftp_server }}/networking/$(cat /etc/hostname)-bridges.cfg -O /etc/network/interfaces.d/vm-bridges.cfg
wget --no-proxy http://{{ tftp_server }}/networking/basic-debian-interface.cfg -O /etc/network/interfaces
# Trusty VMs seem to have their interfaces file overwritten after we write to
# it, so we make it immutable to ensure no further changes take place
# NOTE: We remove the immutable attr in deploy-vms.yml once the instance is up
# and accessible.
[[ "$(lsb_release -sc)" == "trusty" ]] && chattr +i /etc/network/interfaces
cat > /etc/network/if-up.d/post-up-rules <<EOF
#!/usr/bin/env bash
function iptables_filter_rule_add {
if ! iptables -w -t $1 -C $2;then
/sbin/iptables -w -t $1 -I $2
fi
}
# To ensure ssh checksum is correct
iptables_filter_rule_add "mangle" "POSTROUTING -p tcp --dport 22 -j CHECKSUM --checksum-fill"
# To provide internet connectivity to instances
iptables_filter_rule_add "nat" "POSTROUTING -o \$(ip route get 1 | awk '{print $5}') -j MASQUERADE"
# Make sure instances can talk to the metadata server
iptables_filter_rule_add "mangle" "POSTROUTING -p tcp --sport 80 -j CHECKSUM --checksum-fill"
EOF
chmod + /etc/network/if-up.d/post-up-rules