promenade/tools/gate/playbooks/docker-image-build.yaml

58 lines
1.5 KiB
YAML

- hosts: all
tasks:
- name: Install Docker (Debian)
block:
- apt:
name: "{{ item }}"
with_items:
- docker.io
- python-pip
when: ansible_os_family == 'Debian'
- pip:
name: docker
version: 2.7.0
become: True
- name: Debug tag generation inputs
block:
- debug:
var: publish
- debug:
var: tags
- debug:
var: zuul
- debug:
msg: "{{ tags | to_json }}"
- name: Determine tags
shell: echo '{{ tags | to_json }}' | python {{ zuul.project.src_dir }}/tools/image_tags.py
environment:
BRANCH: "{{ zuul.branch }}"
CHANGE: "{{ zuul.change }}"
COMMIT: "{{ zuul.newrev }}"
PATCHSET: "{{ zuul.patchset }}"
register: image_tags
- name: Debug computed tags
debug:
var: image_tags
- name: Docker login
docker_login:
email: "{{ airship_dockerhub_creds.email }}"
password: "{{ airship_dockerhub_creds.password }}"
username: "{{ airship_dockerhub_creds.username }}"
become: True
when: publish
- name: Build (and push) images
docker_image:
name: airshipit/promenade
dockerfile: "Dockerfile"
path: "{{ zuul.project.src_dir }}"
pull: false
push: "{{ publish }}"
tag: "{{ item }}"
with_items: "{{ image_tags.stdout_lines }}"
become: True