ansible-role-haproxy/tasks/haproxy-docker-service.yml

26 lines
1.0 KiB
YAML

---
- name: Manage the composition of haproxy as a docker swarm service
block:
- name: Create the destination directory of the haproxy docker compose file
file: dest={{ haproxy_docker_compose_dir }} state=directory mode='0755'
- name: Install the docker compose file
template: src=haproxy-docker-compose.yml.j2 dest={{ haproxy_docker_compose_dir }}/docker-compose.yml mode='0644'
- name: Create the local haproxy configuration directory
file: dest=/etc/haproxy state=directory mode='0755'
- name: Install a bare haproxy configuration if there's none
copy: src=haproxy-sample.cfg dest=/etc/haproxy/haproxy.cfg mode='0644' force=no
- name: Run the docker compose file to start the service
docker_stack:
name: haproxy
state: present
compose:
- '{{ haproxy_docker_compose_dir }}/docker-compose.yml'
run_once: True
when: docker_swarm_manager_main_node is defined and docker_swarm_manager_main_node | bool
tags: [ 'haproxy', 'docker_haproxy', 'docker_swarm', 'docker' ]