0e0000276a
Added workaround to stop containers which should not be on the node, accouding to a file with list of services which is filled in by ansible's tasks. It allows to implement scale-down and resource migration.
26 lines
768 B
YAML
26 lines
768 B
YAML
|
|
- hosts: [service/haproxy]
|
|
sudo: yes
|
|
tasks:
|
|
- shell: echo {{name}} >> /var/lib/solar/containers_list
|
|
|
|
- shell: docker ps | grep -q {{name}}
|
|
ignore_errors: true
|
|
register: is_running
|
|
|
|
- file: state=directory path=/etc/solar/{{name}}
|
|
# TODO Remove hardcoded path
|
|
- template: src=/vagrant/examples/resources/templates/haproxy.cfg.j2 dest=/etc/solar/{{name}}/haproxy.cfg backup=yes
|
|
notify:
|
|
- haproxy_reload_config
|
|
- shell: docker run -d \
|
|
--net="host" \
|
|
--privileged \
|
|
-v /etc/solar/{{name}}/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro \
|
|
--name {{name}} {{image}}
|
|
when: is_running|failed
|
|
|
|
handlers:
|
|
- name: haproxy_reload_config
|
|
shell: docker restart {{name}}
|