From cc3d27e2e128f1203b7243ef1f7fd4ab207eb4ff Mon Sep 17 00:00:00 2001 From: Pierre Riteau Date: Wed, 8 Apr 2020 19:02:19 +0200 Subject: [PATCH] Fix seed VM provisioning on a remote seed hypervisor The seed VM will fail to provision if the Ansible control host and the seed hypervisor are not the same hosts. This is because Kayobe creates the seed-vm-user-data file on the seed-hypervisor host. It then invokes the jriguera.configdrive role which uses a copy task without remote_src, which fails to find the source file locally on the Ansible control host. Instead we create a local temporary file for seed VM user data. Change-Id: Iabbe4c624b9ad02bb82c323070f99c16e5822966 Story: 2007530 Task: 39338 --- ansible/seed-vm-provision.yml | 21 +++++++++++++++---- ...seed-vm-provisioning-faa8de569ca6bc89.yaml | 7 +++++++ 2 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 releasenotes/notes/fix-remote-seed-vm-provisioning-faa8de569ca6bc89.yaml diff --git a/ansible/seed-vm-provision.yml b/ansible/seed-vm-provision.yml index 581f2c018..cbe19308b 100644 --- a/ansible/seed-vm-provision.yml +++ b/ansible/seed-vm-provision.yml @@ -3,7 +3,6 @@ hosts: seed-hypervisor vars: seed_host: "{{ groups['seed'][0] }}" - seed_user_data_path: "{{ image_cache_path }}/seed-vm-user-data" pre_tasks: - name: Verify the seed host exists in the Ansible inventory fail: @@ -20,6 +19,12 @@ group: "{{ ansible_user_gid }}" become: True + - name: Create a temporary user data file locally + tempfile: + state: file + register: seed_user_data_file + delegate_to: localhost + # The user data script is used to bring up the network interfaces that will # be configured by metadata in the configdrive. For some reason resolv.conf # gets configured with 660 permissions, so fix that here also. @@ -34,7 +39,8 @@ {% endfor %} # Fix permissions of resolv.conf. chmod 644 /etc/resolv.conf - dest: "{{ seed_user_data_path }}" + dest: "{{ seed_user_data_file.path }}" + delegate_to: localhost roles: - role: jriguera.configdrive @@ -55,7 +61,7 @@ {{ hostvars[seed_host].network_interfaces | map('net_configdrive_network_device', seed_host) | list }} - configdrive_config_user_data_path: "{{ seed_user_data_path }}" + configdrive_config_user_data_path: "{{ seed_user_data_file.path }}" tasks: - name: Set a fact containing the configdrive image path @@ -73,9 +79,16 @@ path: "{{ item }}" state: absent with_items: - - "{{ seed_user_data_path }}" - "{{ image_cache_path }}/{{ seed_host | to_uuid }}.gz" + - name: Ensure unnecessary local files are removed + file: + path: "{{ item }}" + state: absent + with_items: + - "{{ seed_user_data_file.path }}" + delegate_to: localhost + - name: Ensure that the seed VM is provisioned hosts: seed-hypervisor vars: diff --git a/releasenotes/notes/fix-remote-seed-vm-provisioning-faa8de569ca6bc89.yaml b/releasenotes/notes/fix-remote-seed-vm-provisioning-faa8de569ca6bc89.yaml new file mode 100644 index 000000000..70a910514 --- /dev/null +++ b/releasenotes/notes/fix-remote-seed-vm-provisioning-faa8de569ca6bc89.yaml @@ -0,0 +1,7 @@ +--- +issues: + - | + Fixes an issue where provisioning a seed VM would fail when the Ansible + control host and the seed hypervisor are different hosts. `See story + 2007530 `_ for more + details.