ansible-role-sofia-taf-mysql/tasks/build-the-pep-image.yml

62 lines
1.8 KiB
YAML

---
- name: Get the Docker file and the pep and nginx templates
block:
- name: Create a temporary directory to store the Docker pieces
ansible.builtin.file:
dest: '{{ item }}'
state: directory
mode: 0700
loop:
- /var/tmp/sofia-taf-mysql-templates
- /var/tmp/sofia-taf-mysql
- name: Download the Docker templates
ansible.builtin.get_url:
url: '{{ pep_url_prefix }}/{{ item }}.j2'
dest: '/var/tmp/sofia-taf-mysql-templates/{{ item }}.j2'
loop:
- Dockerfile
- nginx.default.conf
- pep-swarm.yml
- pep.js
- name: Download the files used to build the Docker image
ansible.builtin.get_url:
url: '{{ pep_url_prefix }}/{{ item }}'
dest: '/var/tmp/sofia-taf-mysql/{{ item }}'
loop:
- nginx.conf
- name: Transform the downloaded templates
ansible.builtin.template:
src: '/var/tmp/sofia-taf-mysql-templates/{{ item }}.j2'
dest: '/var/tmp/sofia-taf-mysql/{{ item }}'
loop:
- Dockerfile
- nginx.default.conf
- pep-swarm.yml
- pep.js
- name: Login into the docker registry
shell: docker login -u {{ docker_registry_username }} -p {{ docker_registry_password }} {{ docker_registry_host }}
- name: Build and push the Docker image
ansible.builtin.docker_image:
build:
path: /var/tmp/sofia-taf-mysql
pull: True
name: '{{ docker_registry_host }}/{{ docker_target_image }}'
tag: latest
push: True
force_source: True
force_tag: True
source: build
state: present
become: False
remote_user: "{{ lookup('env','USER') }}"
delegate_to: localhost
tags:
- sofia_taf_mysql_pep_image
- sofia_taf_msql