Deploying haproxy vs setting up haproxy (reload vs restart)

This commit is contained in:
Samuel Clay 2021-02-25 10:31:29 -05:00
parent 496347a1d7
commit 8ebf75d8ab
5 changed files with 41 additions and 0 deletions

View file

@ -83,6 +83,8 @@ deploy_node:
- ansible-playbook ansible/deploy_node.yml
deploy_task:
- ansible-playbook ansible/deploy_task.yml
deploy_www:
- ansible-playbook ansible/deploy_www.yml
# Provision
app:

21
ansible/deploy_www.yml Normal file
View file

@ -0,0 +1,21 @@
---
- hosts: www
gather_facts: false
vars_files:
- env_vars/base.yml
- env_vars/dev.yml
- roles/letsencrypt/defaults/main.yml
handlers:
- include: 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
- name: Reload haproxy
debug:
msg: Gracefully reloading HAProxy
changed_when: yes
notify: reload haproxy

View file

@ -55,3 +55,10 @@
src: /srv/secrets-newsblur/configs/hosts
dest: /etc/hosts
tags: hosts
- name: "Add inventory_hostname to /etc/hosts"
become: yes
lineinfile:
path: /etc/hosts
line: "127.0.0.1 {{ inventory_hostname }}"
tags: hosts

View file

@ -12,3 +12,8 @@
become: yes
command: docker kill --signal HUP haproxy
listen: reload haproxy
- name: restart haproxy
become: yes
command: docker restart haproxy
listen: restart haproxy

View file

@ -45,3 +45,9 @@
notify: reload haproxy
when: updated_config.changed
changed_when: updated_config.changed
- name: Restart HAProxy
debug:
msg: Restarting HAProxy
changed_when: yes
notify: restart haproxy