Skip to content
This repository was archived by the owner on May 31, 2022. It is now read-only.

Commit 1e55054

Browse files
authored
Merge pull request #217 from stackhpc/infra-vm-followups
Backport Infra VM followups (wallaby)
2 parents 96d66cf + e28e358 commit 1e55054

4 files changed

Lines changed: 53 additions & 12 deletions

File tree

ansible/infra-vm-provision.yml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,12 @@
2929
tags:
3030
- infra-vm-provision
3131
tasks:
32-
- name: Wait for a connection to VM with bootstrap user
33-
wait_for_connection:
32+
- name: Wait for SSH access to the infra VM
33+
wait_for:
34+
host: "{{ hostvars[inventory_hostname].ansible_host }}"
35+
port: 22
36+
state: started
3437
# NOTE: Ensure we exceed the 5 minute DHCP timeout of the eth0
3538
# interface if necessary.
36-
timeout: 600
37-
vars:
38-
# NOTE(wszumski): ansible_host_key_checking variable doesn't seem to
39-
# work, But it would be nice not to fail if the host_key changes.
40-
# We check the hostkey during host configure.
41-
# https://github.com/ansible/ansible/blob/1c34492413dec09711c430745034db0c108227a9/lib/ansible/plugins/connection/ssh.py#L49
42-
# https://github.com/ansible/ansible/issues/49254
43-
ansible_ssh_extra_args: '{{ infra_vm_wait_connection_ssh_extra_args }}'
44-
ansible_user: "{{ bootstrap_user }}"
39+
timeout: 360
40+
delegate_to: localhost

ansible/roles/infra-vms/tasks/deploy.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,26 @@
4949
mime: False
5050
register: stat_result
5151

52+
# NOTE(mgoddard): Prior to the Xena release, the seed VM was provisioned using
53+
# the stackhpc.livirt-vm role with become=true. This resulted in the cached
54+
# image being owned by root. Since Xena, we execute the role without
55+
# become=true. Correct the image ownership to avoid a permission denied error
56+
# when downloading a new image of the same name.
57+
- name: "[{{ vm_name }}] Stat image files"
58+
stat:
59+
path: "{{ image_cache_path }}/{{ item.image | basename }}"
60+
with_items: "{{ vm_hostvars.infra_vm_volumes | selectattr('image', 'defined') }}"
61+
register: image_stat_result
62+
63+
- name: "[{{ vm_name }}] Fix image ownership"
64+
file:
65+
path: "{{ image_cache_path }}/{{ item.item.image | basename }}"
66+
owner: "{{ ansible_facts.user_uid }}"
67+
group: "{{ ansible_facts.user_gid }}"
68+
with_items: "{{ image_stat_result.results }}"
69+
when: item.stat.exists
70+
become: true
71+
5272
- name: "[{{ vm_name }}] Ensure that the VM is provisioned"
5373
include_role:
5474
name: stackhpc.libvirt-vm

ansible/seed-vm-provision.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,26 @@
2929
group: "{{ ansible_facts.user_gid }}"
3030
become: True
3131

32+
# NOTE(mgoddard): Prior to the Xena release, the seed VM was provisioned
33+
# using the stackhpc.livirt-vm role with become=true. This resulted in the
34+
# cached image being owned by root. Since Xena, we execute the role without
35+
# become=true. Correct the image ownership to avoid a permission denied
36+
# error when downloading a new image of the same name.
37+
- name: Stat image files
38+
stat:
39+
path: "{{ image_cache_path }}/{{ item.image | basename }}"
40+
with_items: "{{ hostvars[seed_host].seed_vm_volumes | selectattr('image', 'defined') }}"
41+
register: image_stat_result
42+
43+
- name: Fix image ownership
44+
file:
45+
path: "{{ image_cache_path }}/{{ item.item.image | basename }}"
46+
owner: "{{ ansible_facts.user_uid }}"
47+
group: "{{ ansible_facts.user_gid }}"
48+
with_items: "{{ image_stat_result.results }}"
49+
when: item.stat.exists
50+
become: true
51+
3252
roles:
3353
- role: jriguera.configdrive
3454
# For now assume the VM OS family is the same as the hypervisor's.
@@ -99,7 +119,6 @@
99119
volumes: "{{ hostvars[seed_host].seed_vm_volumes + [seed_vm_configdrive_volume] }}"
100120
interfaces: "{{ hostvars[seed_host].seed_vm_interfaces }}"
101121
console_log_enabled: true
102-
become: True
103122

104123
tasks:
105124
- name: Wait for SSH access to the seed VM
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
fixes:
3+
- |
4+
Fixes an issue where cached seed VM images are unnecessarily owned by root.
5+
See `story 2009277 <https://storyboard.openstack.org/#!/story/2009277>`__
6+
for details.

0 commit comments

Comments
 (0)