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
This commit is contained in:
Pierre Riteau 2020-04-08 19:02:19 +02:00
parent 7110477bcb
commit cc3d27e2e1
2 changed files with 24 additions and 4 deletions

View File

@ -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:

View File

@ -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 <https://storyboard.openstack.org/#!/story/2007530>`_ for more
details.