loci/playbooks/loci-builder.yaml

123 lines
4.0 KiB
YAML

- hosts: all
tasks:
- include_vars: vars.yaml
- name: Ensure dep files are sorted
command: "sort --check -f {{ loci_src_dir }}/{{ item }}"
loop:
- "bindep.txt"
- "pydep.txt"
environment:
LC_ALL: C
# NOTE(evrardjp): While reuse_requirements is very nice and optimises
# checks and gating, there is a race condition here, because
# we are consuming prebuild wheels (see vars.yaml) by default:
# The jobs in zuul can be building a new "requirements" image, working
# And the new "nova" image would still build on previous "requirements"
# image that was last published. This could cause an issue. Instead
# in gating we should build directly what will be consumed.
# NOTE(SamYaple): This process is so we can take advantage of the infra
# DockerHub mirroring as configured through the Docker daemon. We do this
# instead of calling fetch_wheels initially. All-in-all this saves
# bandwidth and time.
- name: Gather wheels to local registry
block:
- docker_image:
name: loci/requirements
tag: "{{ branch }}-{{ item.name }}"
repository: 172.17.0.1:5000/loci/requirements
push: yes
with_items: "{{ distros }}"
async: 1000
poll: 0
register: pull
- async_status:
jid: "{{ item.ansible_job_id }}"
with_items: "{{ pull.results }}"
register: pull_result
until:
- pull_result.finished is defined
- pull_result.finished
retries: 1000
delay: 5
when:
- reuse_requirements | bool
- project != 'requirements'
- name: Build base images
block:
- name: "Build base image for {{ item.name }} asynchronously"
docker_image:
path: "{{ loci_src_dir }}/dockerfiles/{{ item.name }}"
name: base
tag: "{{ item.name }}"
buildargs: "{{ item.buildargs.base }}"
with_items: "{{ distros }}"
async: 1000
poll: 0
register: base
- async_status:
jid: "{{ item.ansible_job_id }}"
with_items: "{{ base.results }}"
register: base_result
until:
- base_result.finished is defined
- base_result.finished
retries: 1000
delay: 5
- name: Build requirements image
block:
- name: "Build requirements image for {{ item.name }}"
docker_image:
path: "{{ loci_src_dir }}"
name: loci/requirements
tag: "{{ branch }}-{{ item.name }}"
repository: 172.17.0.1:5000/loci/requirements
push: yes
pull: False
buildargs: "{{ item.buildargs.requirements }}"
with_items: "{{ distros }}"
async: 1000
poll: 0
register: build
- async_status:
jid: "{{ item.ansible_job_id }}"
with_items: "{{ build.results }}"
register: build_result
until:
- build_result.finished is defined
- build_result.finished
retries: 1000
delay: 5
when:
- (not reuse_requirements) | bool
- project != 'requirements'
- name: Build project images
block:
- name: "Build {{ project }} image for {{ item.name }}"
docker_image:
path: "{{ loci_src_dir }}"
name: loci/{{ project }}
tag: "{{ branch }}-{{ item.name }}"
pull: False
buildargs: "{{ item.buildargs.project }}"
with_items: "{{ distros }}"
async: 1000
poll: 0
register: build
- async_status:
jid: "{{ item.ansible_job_id }}"
with_items: "{{ build.results }}"
register: build_result
until:
- build_result.finished is defined
- build_result.finished
retries: 1000
delay: 5