mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
46 lines
1.4 KiB
YAML
46 lines
1.4 KiB
YAML
---
|
|
- name: DEPLOY -> www
|
|
hosts: haproxy,staging
|
|
gather_facts: false
|
|
vars_files:
|
|
- ../env_vars/base.yml
|
|
- roles/letsencrypt/defaults/main.yml
|
|
handlers:
|
|
- import_tasks: roles/haproxy/handlers/main.yml
|
|
|
|
tasks:
|
|
- name: Template haproxy.cfg file
|
|
template:
|
|
src: /srv/newsblur/docker/haproxy/haproxy.consul.cfg.j2
|
|
dest: /srv/newsblur/docker/haproxy/haproxy.consul.cfg
|
|
when: disable_consul_services_ie_staging is not defined
|
|
register: updated_config_consul
|
|
|
|
- name: Copy staging haproxy.cfg file
|
|
copy:
|
|
src: /srv/newsblur/docker/haproxy/haproxy.staging.cfg
|
|
dest: /srv/newsblur/docker/haproxy/haproxy.consul.cfg
|
|
when: disable_consul_services_ie_staging is defined
|
|
register: updated_config_staging
|
|
|
|
- name: Merge facts
|
|
set_fact:
|
|
updated_config: "{{ updated_config_consul.changed or updated_config_staging.changed }}"
|
|
|
|
- name: Verify HAProxy config
|
|
become: yes
|
|
shell: docker exec haproxy haproxy -c -f /srv/newsblur/docker/haproxy/haproxy.consul.cfg
|
|
register: haproxy_verified
|
|
changed_when: haproxy_verified.rc != 0
|
|
failed_when: haproxy_verified.rc != 0
|
|
|
|
- name: Error in HAProxy config
|
|
debug: var=haproxy_verified
|
|
when: haproxy_verified.rc != 0
|
|
|
|
- name: Reload haproxy
|
|
debug:
|
|
msg: Gracefully reloading HAProxy
|
|
when: haproxy_verified.rc == 0
|
|
changed_when: yes
|
|
notify: reload haproxy
|