Merge "Cleanup block level environment vars"

This commit is contained in:
Jenkins 2017-05-18 09:10:31 +00:00 committed by Gerrit Code Review
commit a391c5e007
3 changed files with 9 additions and 45 deletions

View File

@ -1,4 +1,6 @@
- when: overcloud_nodes
environment:
LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}"
block:
# Generate MAC addresses that we'll use for the overcloud nodes.
@ -17,8 +19,6 @@
virsh vol-info --pool '{{libvirt_volume_pool}}' '{{item.name}}.qcow2'
register: overcloud_vol_check
ignore_errors: true
environment:
LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}"
with_items: "{{ overcloud_nodes }}"
- name: Create overcloud vm storage
@ -26,8 +26,6 @@
virsh vol-create-as '{{ libvirt_volume_pool }}'
'{{ item.item.name }}'.qcow2 '{{ flavors[item.item.flavor].disk }}'G
--format qcow2
environment:
LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}"
when: item|failed
with_items: "{{ overcloud_vol_check.results }}"

View File

@ -27,6 +27,9 @@
LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}"
- when: undercloud_vol_check|failed
environment:
LIBGUESTFS_BACKEND: direct
LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}"
block:
# Conditionally include a playbook for all the images specified
# in options that downloads, cache and extract if tar archived
@ -62,9 +65,6 @@
--upload {{ working_dir }}/{{ item }}:/home/{{ undercloud_user }}/{{ item }}
--run-command 'chown {{ undercloud_user }}:{{ undercloud_user }} /home/{{ undercloud_user }}/{{ item }}'
changed_when: true
environment:
LIBGUESTFS_BACKEND: direct
LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}"
with_items: "{{ inject_images | default('') }}"
when: overcloud_as_undercloud|bool or use_external_images|bool
@ -75,9 +75,6 @@
virt-customize -a {{ working_dir }}/undercloud.qcow2
--upload {{ working_dir }}/instackenv.json:/home/{{ undercloud_user }}/instackenv.json
--run-command 'chown {{ undercloud_user }}:{{ undercloud_user }} /home/{{ undercloud_user }}/instackenv.json'
environment:
LIBGUESTFS_BACKEND: direct
LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}"
when: inject_instackenv|bool
# Copy the undercloud public key to the virthost, because we're going
@ -105,8 +102,6 @@
--run-command 'chown -R {{item.owner}}:{{item.group}} {{item.homedir}}/.ssh'
--run-command 'chmod 0700 {{item.homedir}}/.ssh'
--run-command 'chmod 0600 {{item.homedir}}/.ssh/authorized_keys'
environment:
LIBGUESTFS_BACKEND: direct
with_items:
- homedir: /root
owner: root
@ -125,8 +120,6 @@
--upload '{{ working_dir }}/id_rsa_virt_power:/root/.ssh/id_rsa_virt_power'
--run-command 'chown root:root /root/.ssh/id_rsa_virt_power'
--run-command 'chmod 0600 /root/.ssh/id_rsa_virt_power'
environment:
LIBGUESTFS_BACKEND: direct
- name: Create undercloud customize script
template:
@ -156,8 +149,6 @@
command: >
virt-customize -a {{ working_dir }}/undercloud.qcow2
--selinux-relabel
environment:
LIBGUESTFS_BACKEND: direct
# NOTE(trown) Nested blocks do not seem to work as expected so instead using
# conditionals with AND to simulate the same thing.
@ -245,6 +236,8 @@
set_fact: overcloud_as_undercloud=true
- when: undercloud_vol_check|failed
environment:
LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}"
block:
# Create a libvirt volume and upload the undercloud image to
# libvirt.
@ -253,16 +246,12 @@
virsh vol-create-as {{ libvirt_volume_pool}}
{{ undercloud_node.name }}.qcow2
{{ flavors[undercloud_node.flavor].disk }}G --format qcow2
environment:
LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}"
- name: Upload undercloud volume to storage pool
command: >
virsh -k 0 vol-upload --pool '{{ libvirt_volume_pool }}'
'{{ undercloud_node.name }}.qcow2'
'{{ working_dir }}/undercloud.qcow2'
environment:
LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}"
async: 600
poll: 10
@ -341,4 +330,3 @@
template:
src: ssh.config.j2
dest: "{{ local_working_dir }}/ssh.config.ansible"

View File

@ -13,6 +13,8 @@
# If libvirt isn't available we can skip everything else.
- when: libvirt_check|success
environment:
LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}"
block:
- when: overcloud_nodes
@ -25,8 +27,6 @@
with_items: "{{ overcloud_nodes }}"
ignore_errors: true
register: overcloud_check
environment:
LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}"
# Destroy and undefine the overcloud nodes.
- name: Destroy overcloud vms
@ -35,16 +35,12 @@
when: item|success
with_items: "{{ overcloud_check.results }}"
ignore_errors: true
environment:
LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}"
- name: Undefine overcloud vms
command:
virsh undefine "{{ item.item.name }}"
when: item|success
with_items: "{{ overcloud_check.results }}"
environment:
LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}"
# The `virsh vol-dumpxml ... > /dev/null` is here (and elsewhere) due to
# [1293804].
@ -58,8 +54,6 @@
'{{ item.name }}'.qcow2
with_items: "{{ overcloud_nodes }}"
ignore_errors: true
environment:
LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}"
# Do the same thing to the undercloud node.
- name: Check undercloud vm
@ -67,23 +61,17 @@
virsh domid "{{ undercloud_node.name }}"
ignore_errors: true
register: undercloud_check
environment:
LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}"
- name: Destroy undercloud vm
command: >
virsh destroy "{{ undercloud_node.name }}"
when: undercloud_check|success
ignore_errors: true
environment:
LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}"
- name: Undefine undercloud vm
command: >
virsh undefine "{{ undercloud_node.name }}"
when: undercloud_check|success
environment:
LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}"
- name: Delete undercloud vm storage
shell: |
@ -92,8 +80,6 @@
virsh vol-delete --pool '{{ libvirt_volume_pool }}' \
'{{ undercloud_node.name }}'.qcow2
ignore_errors: true
environment:
LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}"
- name: Destroy intermediate disk image
file:
@ -105,8 +91,6 @@
virsh pool-uuid "{{ libvirt_volume_pool }}"
register: pool_check
ignore_errors: true
environment:
LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}"
# See https://www.redhat.com/archives/libvirt-users/2016-March/msg00123.html
# TL;DR: ensure that the pool really exists if the previous
@ -116,23 +100,17 @@
virsh pool-dumpxml "{{ libvirt_volume_pool }}" |
virsh pool-define /dev/stdin
when: pool_check|success
environment:
LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}"
- name: Destroy volume pool
command: >
virsh pool-destroy "{{ libvirt_volume_pool }}"
when: pool_check|success
ignore_errors: true
environment:
LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}"
- name: Undefine volume pool
command: >
virsh pool-undefine "{{ libvirt_volume_pool }}"
when: pool_check|success
environment:
LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}"
- name: Get UID of pool user
command: id -u "{{ ansible_user_id }}"