tripleo-ci/roles/oooci-build-images/tasks/main.yaml

149 lines
4.3 KiB
YAML

---
- name: Get python_v fact for py2 or py3 common vars
include_tasks: check_set_py3.yaml
- name: Include OS specific variables for C7 or C9
include_vars: "centos-{{ ansible_distribution_major_version }}.yaml"
when:
- ansible_distribution == "CentOS"
- ansible_distribution_major_version is version('7', '==') or
ansible_distribution_major_version is version('9', '==')
- name: Make sure logs directory exists
file:
path: '{{ workspace }}/logs'
state: directory
- name: Set dib related facts used by tripleo-ci build-image role build template
set_fact:
dib_local_image: "{{ workspace }}/{{ tripleo_image_source | urlsplit('path') | basename }}"
dib_node_dist: "{{ (ansible_distribution == 'RedHat') | ternary('rhel', 'centos') }}"
cacheable: true
when: tripleo_image_source is defined
- name: Install libselinux-python3
package:
name: libselinux-python3
state: present
become: true
- name: Download TripleO source image
get_url:
url: "{{ tripleo_image_source }}"
dest: "{{ dib_local_image }}"
timeout: 20
register: result
until: result is success
retries: 60
delay: 10
vars:
ansible_python_interpreter: /usr/bin/python3
- name: Install qemu-img for image build
package:
name: qemu-img
state: present
become: true
- name: Install python3-devel
package:
name: python3-devel # required for python-tripleoclient pip install
state: present
become: true
- name: Install python-tripleoclient for Image build
package:
name: "python*-tripleoclient"
state: present
become: true
- name: Generate build-images.sh script
template:
src: templates/build-images.sh.j2
dest: "{{ workspace }}/build_images.sh"
mode: 0777
force: true
- name: Run build-images.sh
args:
chdir: '{{ workspace }}'
shell: bash build_images.sh > {{ workspace }}/logs/script_build.log 2> {{ workspace }}/logs/script_build-err.log
changed_when: true
- when: tripleo_image_source is defined
block:
- name: check if overcloud images were built
stat:
path: "{{ workspace }}/overcloud-full.qcow2"
register: overcloud_stat_result
- name: check if overcloud-hardened-uefi-full images were built
stat:
path: "{{ workspace }}/overcloud-hardened-uefi-full.qcow2"
register: overcloud_hardened_uefi_stat_result
- name: check if ipa images were built
stat:
path: "{{ workspace }}/ironic-python-agent.kernel"
register: ipa_stat_result
- when: ipa_stat_result.stat.exists|bool
block:
- name: ironic-python-agent
archive:
path:
- "{{ workspace }}/ironic-python-agent.initramfs"
- "{{ workspace }}/ironic-python-agent.kernel"
dest: "{{ ansible_user_dir }}/ironic-python-agent.tar"
format: tar
- name: Create md5sums
shell:
cmd: |
md5sum ironic-python-agent.tar > ironic-python-agent.tar.md5
args:
chdir: "{{ ansible_user_dir }}"
- when: overcloud_stat_result.stat.exists|bool
block:
- name: overcloud-full
archive:
path:
- "{{ workspace }}/overcloud-full.qcow2"
- "{{ workspace }}/overcloud-full.initrd"
- "{{ workspace }}/overcloud-full.vmlinuz"
dest: "{{ ansible_user_dir }}/overcloud-full.tar"
format: tar
- name: Create md5sums
shell:
cmd: |
md5sum overcloud-full.tar > overcloud-full.tar.md5
args:
chdir: "{{ ansible_user_dir }}"
- when: overcloud_hardened_uefi_stat_result.stat.exists|bool
block:
- name: Move image to {{ ansible_user_dir }}
command: "mv {{ workspace }}/overcloud-hardened-uefi-full.qcow2 {{ ansible_user_dir }}"
when: workspace != ansible_user_dir
- name: Create md5sums
shell:
cmd: |
md5sum overcloud-hardened-uefi-full.qcow2 > overcloud-hardened-uefi-full.qcow2.md5
args:
chdir: "{{ ansible_user_dir }}"
- block:
- name: Run Image sanity on overcloud image
include_tasks: image_sanity.yaml
become: true
when:
- tripleo_image_type is search("overcloud-full")
- image_sanity | bool
- overcloud_stat_result.stat.exists|bool