Translate tripleo-ci logic of when to build images to ansible
In order to combine the tripleo-ci OVB playbook with what we have here, we need to implement the logic around when to build images[1]. We default to fetching pre-built images. However, in the case we are testing a change to a project that can affect the image build or the case we are running a periodic job, we want to build the images. [1] https://github.com/openstack-infra/tripleo-ci/blob/master/scripts/to_build Change-Id: I72169d4c6ae891397916f831e56eb883d047c89b
This commit is contained in:
parent
5cc18e2bca
commit
d77ea8c6d8
@ -9,6 +9,11 @@
|
||||
roles:
|
||||
- undercloud-setup
|
||||
|
||||
# Small playbook with logic for when to build images or not.
|
||||
# The logic there can be completely overridden by setting the
|
||||
# to_build variable.
|
||||
- include: to-build-or-not-to-build.yml
|
||||
|
||||
- name: Inventory the undercloud instance
|
||||
hosts: localhost
|
||||
gather_facts: yes
|
||||
|
49
playbooks/to-build-or-not-to-build.yml
Normal file
49
playbooks/to-build-or-not-to-build.yml
Normal file
@ -0,0 +1,49 @@
|
||||
---
|
||||
- name: Decide whether we need to build images
|
||||
hosts: undercloud
|
||||
vars:
|
||||
# We always want to build images when we have changes in this
|
||||
# list becuase these repos can affect the image building itelf
|
||||
# This list is overridable via the "always_build_list" var if
|
||||
# needed.
|
||||
default_projects_need_build_list:
|
||||
- diskimage-builder
|
||||
- tripleo-image-elements
|
||||
- tripleo-puppet-elements
|
||||
- instack-undercloud
|
||||
- python-tripleoclient
|
||||
- tripleo-common
|
||||
tasks:
|
||||
# The next two tasks make the list of ZUUL_CHANGES look like our build list
|
||||
# after we cleanup the extra stuff there, we can just intersect the two
|
||||
# lists in order to match.
|
||||
- name: Cleanup front of ZUUL_CHANGES
|
||||
set_fact:
|
||||
zuul_changes: "{{ lookup('env', 'ZUUL_CHANGES')|regex_replace('openstack/', '') }}"
|
||||
|
||||
- name: Cleanup end of ZUUL_CHANGES
|
||||
set_fact:
|
||||
zuul_changes: "{{ zuul_changes|regex_replace(':[a-z]*:refs/changes/\\d{2}/\\d{6}/\\d{1}','') }}"
|
||||
|
||||
- name: Split zuul_changes to a list
|
||||
set_fact:
|
||||
zuul_changes: "{{ zuul_changes.split('^') }}"
|
||||
|
||||
- name: compare zuul_changes list to our always_build_list
|
||||
set_fact:
|
||||
projects_need_build: "{{ zuul_changes | intersect(projects_need_build_list|default(default_projects_need_build_list)) }}"
|
||||
|
||||
- name: Default to using cached images
|
||||
set_fact:
|
||||
to_build: false
|
||||
|
||||
- name: Build images when we have a change in the always build list
|
||||
set_fact:
|
||||
to_build: true
|
||||
when: projects_need_build != []
|
||||
|
||||
- name: Always build images in the periodic jobs
|
||||
set_fact:
|
||||
to_build: true
|
||||
when: "{{ lookup('env', 'PERIODIC')|default('0')|int == 1 }}"
|
||||
|
Loading…
Reference in New Issue
Block a user