ansible-role-epas/tasks/main.yml

58 lines
2.3 KiB
YAML

---
- name: Manage the installation of the ePAS configuration of the swarm service
block:
- name: Create the directory where the DB init script is going to be installed
file: dest={{ epas_compose_dir }} state=directory
- name: Install the DB initialization script
template: src=pg-create-user-db.sh.j2 dest={{ epas_compose_dir }}/pg-create-user-db.sh owner=root group=root mode='0555'
when:
- epas_dockerized_db
- epas_docker_db_node == ansible_fqdn
tags: [ 'epas', 'epas_swarm', 'epas_db' ]
- name: Manage the installation of the ePAS configuration of the swarm service
block:
- name: Add the label that will be used as a constraint for the attachments volume
docker_node:
hostname: '{{ epas_docker_attachments_node }}'
labels:
epas_storage: 'attachments'
labels_state: 'merge'
- name: Add the label that will be used as a constraint for the postgresql DB
docker_node:
hostname: '{{ epas_docker_db_node }}'
labels:
epas_pg_data: 'epas_db'
labels_state: 'merge'
when: epas_dockerized_db
- name: Create the directory where the compose file will be placed
file: dest={{ epas_compose_dir }} state=directory owner=root group=root mode=0750
- name: Install the docker compose file
template: src=epas-docker-compose.yml.j2 dest={{ epas_compose_dir }}/docker-epas-stack.yml owner=root group=root mode='0400'
- name: Login into the IIT registry
shell: docker login -u {{ epas_docker_registry_user }} -p {{ epas_docker_registry_pwd }} {{ epas_docker_registry }}
- name: Start the ePAS stack
docker_stack:
name: '{{ epas_docker_stack_name }}'
state: present
with_registry_auth: True
compose:
- '{{ epas_compose_dir }}/docker-epas-stack.yml'
# - name: Connect the ePAS service to the haproxy-public network
# command: docker service update --network-add {{ epas_haproxy_public_net }} {{ item }} --update-delay 30s --update-parallelism 1
# with_items:
# - '{{ epas_docker_stack_name }}_{{ epas_docker_service_server_name }}'
# ignore_errors: True
# when: epas_behind_haproxy
when: docker_swarm_manager_node is defined and docker_swarm_manager_node
tags: [ 'epas', 'epas_swarm', 'epas_server' ]