diff --git a/tasks/haproxy-docker-service.yml b/tasks/haproxy-docker-service.yml index 07576c0..b8a923b 100644 --- a/tasks/haproxy-docker-service.yml +++ b/tasks/haproxy-docker-service.yml @@ -1,4 +1,14 @@ --- +- name: Manage the composition of haproxy as a docker swarm service + block: + - 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 + + tags: [ 'haproxy', 'docker_haproxy', 'docker_swarm', 'docker' ] + - name: Manage the composition of haproxy as a docker swarm service block: - name: Create the destination directory of the haproxy docker compose file @@ -7,12 +17,6 @@ - name: Install the docker compose file template: src=haproxy-docker-stack.yml.j2 dest={{ haproxy_docker_compose_dir }}/docker-haproxy-stack.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 diff --git a/templates/haproxy-docker-stack.yml.j2 b/templates/haproxy-docker-stack.yml.j2 index b7f4b76..3b256f8 100644 --- a/templates/haproxy-docker-stack.yml.j2 +++ b/templates/haproxy-docker-stack.yml.j2 @@ -6,6 +6,7 @@ services: volumes: - {{ haproxy_cert_dir }}:{{ haproxy_cert_dir }}:ro - /etc/haproxy:/usr/local/etc/haproxy:ro + - /var/run/docker.sock:/var/run/docker.sock ports: - target: {{ haproxy_default_port }} published: {{ haproxy_default_port }}