From ce29ea23d10b5467ff314adfb09ee618e09fef57 Mon Sep 17 00:00:00 2001 From: Matt Thompson Date: Fri, 22 Sep 2017 13:06:47 -0400 Subject: [PATCH] Updates for Trusty VMs Currently, attempting to use Trusty (14.04) VMs causes VMs to not provision correctly due to a grub-install error. With respect to this specific issue, this commit updates vm.preseed.j2 by removing some grub-installer options which were not present before the ansible rewrite. Secondly, with that change in place, VMs do not come online on their 10.0.236 addresses as something is overwriting /etc/networking/interfaces, which wipes out the source of the /etc/network/interfaces.d directory. Bug [1] seems to indicate this is in fact an issue and has been resolved, however attempts at using this preseed option (netcfg/target_network_config) were not successful. As a workaround, we simply chattr +i the interfaces file in vm-post-install-script.sh.j2, and then remove the attr in deploy-vms.yml when the instance is up an accessible. [1] https://bugs.launchpad.net/ubuntu/+source/netcfg/+bug/1361902 Change-Id: I12d0c5108d1df0ab02b69d1b8cdb271a02999602 --- multi-node-aio/playbooks/deploy-vms.yml | 14 ++++++++++++++ .../pxe/debian/vm-post-install-script.sh.j2 | 5 +++++ multi-node-aio/playbooks/pxe/debian/vm.preseed.j2 | 2 -- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/multi-node-aio/playbooks/deploy-vms.yml b/multi-node-aio/playbooks/deploy-vms.yml index 289a0d3b..bad7289a 100644 --- a/multi-node-aio/playbooks/deploy-vms.yml +++ b/multi-node-aio/playbooks/deploy-vms.yml @@ -138,6 +138,20 @@ - src: "{{ lookup('env', 'HOME') }}/.ssh/id_rsa.pub" dest: /root/.ssh/id_rsa.pub +# In vm-post-install-script.sh.j2 we chattr +i the interfaces file to prevent +# the preseed system from overwriting the file after we've modified it. The +# task below simply removes the immutable attribute. +- name: Remove immutable attr from /etc/network/interfaces + hosts: vm_servers + gather_facts: true + tasks: + - file: + path: /etc/network/interfaces + attr: "" + when: + - ansible_distribution | lower == "ubuntu" + - ansible_distribution_release | lower == "trusty" + environment: "{{ deployment_environment_variables | default({}) }}" tags: diff --git a/multi-node-aio/playbooks/pxe/debian/vm-post-install-script.sh.j2 b/multi-node-aio/playbooks/pxe/debian/vm-post-install-script.sh.j2 index 20034141..ee9ee5f6 100644 --- a/multi-node-aio/playbooks/pxe/debian/vm-post-install-script.sh.j2 +++ b/multi-node-aio/playbooks/pxe/debian/vm-post-install-script.sh.j2 @@ -13,6 +13,11 @@ echo "{{ tftp_ssh_key }}" >> /root/.ssh/authorized_keys 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 <