kayobe/ansible/test-image.yml
Mark Goddard f349038b1d Make installation of epel-release optional
The epel-release package provides a yum repository configuration for
EPEL, and points to the upstream EPEL mirrors. In some cases this is
undesirable, such as when a local EPEL mirror is available, or access to
the public repositories is not possible.

This change makes it possible to skip installation of epel-release, by
setting 'yum_install_epel' to 'false'.

Change-Id: Ib685b0c3e21df01c4dd177771f019fae4bb90e66
Story: 2003277
Task: 24218
2018-08-02 15:30:33 +00:00

87 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: "{{ virtualenv_path }}/shade"
roles:
- role: stackhpc.os-shade
os_shade_install_epel: "{{ yum_install_epel }}"
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