Skip to content

Commit

Permalink
Haproxy: Make sure certificates can be deployed in case there is no c…
Browse files Browse the repository at this point in the history
…ertificate present yet
  • Loading branch information
quartje committed Jul 2, 2024
1 parent 817e053 commit 56d084f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions roles/haproxy/tasks/get_acme_certs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
become_user: acme
become: true

- name: Deploy the certificates to haproxy
- name: Deploy the certificates to haproxy without the need for haproxy to run
ansible.builtin.shell:
cmd: "DEPLOY_HAPROXY_HOT_UPDATE=yes DEPLOY_HAPROXY_STATS_SOCKET=/var/lib/haproxy/haproxy.stats DEPLOY_HAPROXY_PEM_PATH=/etc/haproxy/certs /home/acme/.acme.sh/acme.sh --deploy -d {{ base_domain }} --deploy-hook haproxy"
cmd: "DEPLOY_HAPROXY_PEM_PATH=/etc/haproxy/certs /home/acme/.acme.sh/acme.sh --deploy -d {{ base_domain }} --deploy-hook haproxy"
become_user: acme
become: true
7 changes: 7 additions & 0 deletions roles/haproxy/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- socat
- git
state: present
update_cache: true
register: haproxy_package_installed
until: haproxy_package_installed is succeeded

Expand Down Expand Up @@ -176,6 +177,12 @@
state: started
enabled: true

- name: Deploy the certificates to haproxy while running, ensuring that when updating certs it will hot reload haproxy
ansible.builtin.shell:
cmd: "DEPLOY_HAPROXY_HOT_UPDATE=yes DEPLOY_HAPROXY_STATS_SOCKET=/var/lib/haproxy/haproxy.stats DEPLOY_HAPROXY_PEM_PATH=/etc/haproxy/certs /home/acme/.acme.sh/acme.sh --deploy -d {{ base_domain }} --deploy-hook haproxy"
become_user: acme
become: true

- name: Add lbops user to sudoers and let it reload haproxy
ansible.builtin.copy:
src: lbops
Expand Down

0 comments on commit 56d084f

Please sign in to comment.