From 2a66c77525b15d4efb95860f4de045ed4d92d59d Mon Sep 17 00:00:00 2001
From: Mark Goddard <mark@stackhpc.com>
Date: Mon, 7 Aug 2017 12:00:19 +0000
Subject: [PATCH] Improvements to seed VM provisioning

Fully bounce interfaces, fix permissions of /etc/resolv.conf (it gets written out with 0660,
but should be 0644), increase SSH wait timeout to 360 seconds. The latter change allows for
a commonly used 5 minute DHCP timeout which may be applied before cloud-init is run.
---
 ansible/seed-vm-provision.yml | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/ansible/seed-vm-provision.yml b/ansible/seed-vm-provision.yml
index a8df66fba..130d5db3b 100644
--- a/ansible/seed-vm-provision.yml
+++ b/ansible/seed-vm-provision.yml
@@ -19,15 +19,19 @@
         state: directory
 
     # The user data script is used to bring up the network interfaces that will
-    # be configured by metadata in the configdrive. It could be used for other
-    # things in future if necessary.
+    # be configured by metadata in the configdrive. For some reason resolv.conf
+    # gets configured with 660 permissions, so fix that here also.
     - name: Ensure the user data file exists
       copy:
         content: |
           #!/bin/bash
           {% for interface in seed_hostvars.network_interfaces | map('net_interface', seed_host) %}
+          # Bounce {{ interface }}.
+          ifdown {{ interface }}
           ifup {{ interface }}
           {% endfor %}
+          # Fix permissions of resolv.conf.
+          chmod 644 /etc/resolv.conf
         dest: "{{ seed_user_data_path }}"
 
   roles:
@@ -110,3 +114,6 @@
         host: "{{ seed_hostvars.ansible_host }}"
         port: 22
         state: started
+        # NOTE: Ensure we exceed the 5 minute DHCP timeout of the eth0
+        # interface if necessary.
+        timeout: 360