Move deploy image ID finding to enrolment role

The OpenStack client Python package is not necessarily installed in the
Tenks virtualenv until the role is run, so we need to query OpenStack
for the image IDs inside the role.
This commit is contained in:
Will Miller 2018-09-21 16:13:02 +00:00
parent 7fe0942a03
commit e81eb6d6ca
3 changed files with 25 additions and 23 deletions

View File

@ -12,29 +12,12 @@
credentials exist in your environment, perhaps by sourcing your RC file. credentials exist in your environment, perhaps by sourcing your RC file.
when: not lookup('env', 'OS_USERNAME') when: not lookup('env', 'OS_USERNAME')
# This command will return the UUIDs, regardless of whether deploy_kernel
# and deploy_ramdisk are image UUIDs or names.
- name: Get OpenStack deployment image UUIDs
command: >-
'{{ virtualenv_path }}/bin/openstack' image show
'{{ item }}' --format value --column id
loop:
- "{{ deploy_kernel }}"
- "{{ deploy_ramdisk }}"
# deploy_kernel/ramdisk default to none. We don't need to know them for
# enrolment to continue.
when: item is not none
register: deploy_image_ids
changed_when: false
- name: Perform Ironic enrolment for each hypervisor's nodes - name: Perform Ironic enrolment for each hypervisor's nodes
include_role: include_role:
name: ironic-enrolment name: ironic-enrolment
vars: vars:
ironic_deploy_kernel_uuid: >- ironic_deploy_kernel: "{{ deploy_kernel }}"
{{ deploy_image_ids.results.0.stdout | default(omit) }} ironic_deploy_ramdisk: "{{ deploy_ramdisk }}"
ironic_deploy_ramdisk_uuid: >-
{{ deploy_image_ids.results.1.stdout | default(omit) }}
ironic_nodes: "{{ alloc.value.nodes }}" ironic_nodes: "{{ alloc.value.nodes }}"
ironic_hypervisor: "{{ alloc.key }}" ironic_hypervisor: "{{ alloc.key }}"
ironic_virtualenv_path: "{{ virtualenv_path }}" ironic_virtualenv_path: "{{ virtualenv_path }}"

View File

@ -3,10 +3,10 @@
ironic_nodes: [] ironic_nodes: []
# The hostname of the hypervisor where these nodes exist. # The hostname of the hypervisor where these nodes exist.
ironic_hypervisor: ironic_hypervisor:
# The Glance UUID of the image to use for the deployment kernel. # The Glance name or UUID of the image to use for the deployment kernel.
ironic_deploy_kernel_uuid: ironic_deploy_kernel:
# The Glance UUID of the image to use for the deployment ramdisk. # The Glance name UUID of the image to use for the deployment ramdisk.
ironic_deploy_ramdisk_uuid: ironic_deploy_ramdisk:
# The path to the virtualenv in which to install the OpenStack clients. # The path to the virtualenv in which to install the OpenStack clients.
ironic_virtualenv_path: ironic_virtualenv_path:
# The URL of the upper constraints file to pass to pip when installing Python # The URL of the upper constraints file to pass to pip when installing Python

View File

@ -16,12 +16,31 @@
-c {{ ironic_python_upper_constraints_url }} -c {{ ironic_python_upper_constraints_url }}
virtualenv: "{{ ironic_virtualenv_path }}" virtualenv: "{{ ironic_virtualenv_path }}"
# This command will return the UUIDs, regardless of whether
# ironic_deploy_kernel and ironic_deploy_ramdisk are image UUIDs or names.
- name: Get OpenStack deployment image UUIDs
command: >-
'{{ ironic_virtualenv_path }}/bin/openstack' image show
'{{ item }}' --format value --column id
loop:
- "{{ ironic_deploy_kernel }}"
- "{{ ironic_deploy_ramdisk }}"
# ironic_deploy_kernel/ramdisk default to none. We don't need to know them
# for enrolment to continue.
when: item is not none
register: deploy_image_ids
changed_when: false
- name: Configure Ironic node enrolment - name: Configure Ironic node enrolment
include_tasks: node.yml include_tasks: node.yml
vars: vars:
node: "{{ ironic_node }}" node: "{{ ironic_node }}"
ipmi_port: >- ipmi_port: >-
{{ hostvars[ironic_hypervisor].ipmi_port_range_start + port_offset }} {{ hostvars[ironic_hypervisor].ipmi_port_range_start + port_offset }}
ironic_deploy_kernel_uuid: >-
{{ deploy_image_ids.results.0.stdout | default(ironic_deploy_kernel) }}
ironic_deploy_ramdisk_uuid: >-
{{ deploy_image_ids.results.1.stdout | default(ironic_deploy_ramdisk) }}
loop: "{{ ironic_nodes | sort(attribute='name') }}" loop: "{{ ironic_nodes | sort(attribute='name') }}"
loop_control: loop_control:
loop_var: ironic_node loop_var: ironic_node