86 lines
2.9 KiB
YAML
86 lines
2.9 KiB
YAML
---
|
|
- name: Ensure user images are built and registered with Glance
|
|
hosts: controllers[0]
|
|
vars:
|
|
image_build_dir: "{{ ansible_user_dir }}/images/dib"
|
|
image_name: centos7
|
|
image_os_element: centos7
|
|
image_base_elements:
|
|
- dhcp-all-interfaces
|
|
- enable-serial-console
|
|
image_is_whole_disk: True
|
|
image_whole_disk_elements:
|
|
- vm
|
|
image_partition_elements:
|
|
- baremetal
|
|
- grub2
|
|
image_extra_elements: []
|
|
image_elements: "{{ image_base_elements + (image_whole_disk_elements if image_is_whole_disk|bool else image_partition_elements) + image_extra_elements }}"
|
|
os_shade_venv: "{{ ansible_env['PWD'] }}/shade-venv"
|
|
roles:
|
|
- role: stackhpc.os-shade
|
|
tasks:
|
|
- name: Ensure diskimage-builder package is installed
|
|
yum:
|
|
name: diskimage-builder
|
|
state: installed
|
|
become: True
|
|
|
|
- name: Ensure image build directory exists
|
|
file:
|
|
path: "{{ image_build_dir }}"
|
|
state: directory
|
|
|
|
- name: Display image elements
|
|
debug:
|
|
var: image_elements
|
|
|
|
- name: Ensure CentOS 7 image is built
|
|
command: >
|
|
disk-image-create
|
|
{{ image_os_element }}
|
|
{{ image_elements|join(' ') }}
|
|
-o {{ image_name }}
|
|
args:
|
|
chdir: "{{ image_build_dir }}"
|
|
creates: "{{ image_build_dir }}/{{ image_name }}.qcow2"
|
|
|
|
# Note that setting this via a play or task variable seems to not
|
|
# evaluate the Jinja variable reference, so we use set_fact.
|
|
- name: Update the Ansible python interpreter fact to point to the shade virtualenv
|
|
set_fact:
|
|
ansible_python_interpreter: "{{ os_shade_venv }}/bin/python"
|
|
|
|
- name: Ensure test deployment ramdisk and kernel images are registered with Glance
|
|
os_image:
|
|
auth: "{{ openstack_auth }}"
|
|
name: "{{ image_name }}.{{ item.ext }}"
|
|
container_format: "{{ item.container_format }}"
|
|
disk_format: "{{ item.disk_format }}"
|
|
filename: "{{ image_build_dir }}/{{ image_name }}.{{ item.ext }}"
|
|
state: present
|
|
with_items:
|
|
- { container_format: ari, disk_format: ari, ext: initrd }
|
|
- { container_format: aki, disk_format: aki, ext: vmlinuz }
|
|
register: r_and_k_result
|
|
when: not image_is_whole_disk|bool
|
|
|
|
- name: Ensure test deployment image is registered with Glance
|
|
os_image:
|
|
auth: "{{ openstack_auth }}"
|
|
name: "{{ image_name }}"
|
|
container_format: bare
|
|
disk_format: qcow2
|
|
filename: "{{ image_build_dir }}/{{ image_name }}.qcow2"
|
|
state: present
|
|
|
|
# FIXME: This does not seem to work :(
|
|
- name: Ensure test deployment image has kernel and ramdisk properties
|
|
os_image:
|
|
auth: "{{ openstack_auth }}"
|
|
name: "{{ image_name }}"
|
|
ramdisk: "{{ image_name }}.initrd"
|
|
kernel: "{{ image_name }}.vmlinuz"
|
|
state: present
|
|
when: not image_is_whole_disk|bool
|