41 lines
1.4 KiB
YAML
41 lines
1.4 KiB
YAML
---
|
|
# tasks file for haproxy
|
|
|
|
# socat is required by the acme.sh haproxy deploy hook to hot update
|
|
# certificates through the stats socket (DEPLOY_HAPROXY_HOT_UPDATE)
|
|
- name: Install acme.sh
|
|
ansible.builtin.apt:
|
|
name:
|
|
- acme.sh
|
|
- socat
|
|
become: true
|
|
|
|
# acme.sh 3.1.1 (Debian 13 package) sends "set ssl cert" with `echo -e`,
|
|
# which dash (/bin/sh) does not support: haproxy receives "-e set ssl cert"
|
|
# and the hot update fails. Apply the upstream fix (printf '%b\n').
|
|
# No-op once the packaged hook is fixed.
|
|
- name: Fix acme.sh haproxy deploy hook hot update under dash
|
|
ansible.builtin.replace:
|
|
path: /usr/share/acme.sh/deploy/haproxy.sh
|
|
regexp: 'echo -e ''(\$\{_cmdpfx\}set ssl cert )'
|
|
replace: 'printf ''%b\\n'' ''\1'
|
|
become: true
|
|
|
|
# Always run: also covers instances where acme.sh is already installed
|
|
- name: Ensure to install cronjob
|
|
ansible.builtin.command:
|
|
argv:
|
|
- acme.sh
|
|
- --install-cronjob
|
|
become: true
|
|
|
|
# One include per command: a failing command stops the host, so a --deploy
|
|
# never runs after a failed --issue (a plain loop would continue).
|
|
- name: Execute acme.sh commands
|
|
ansible.builtin.include_tasks:
|
|
file: acmesh_command.yml
|
|
loop: "{{ haproxy_acmesh }}"
|
|
loop_control:
|
|
loop_var: haproxy_acmesh_item
|
|
label: "{{ haproxy_acmesh_item.name | default(haproxy_acmesh_item.command | join(' ')) }}"
|