Skip to content

Commit

Permalink
Haproxy: Various fixes - upgrade to haproxy 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
quartje committed Jun 17, 2024
1 parent dd5a6dd commit 821a93e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 deletions.
7 changes: 5 additions & 2 deletions roles/haproxy/tasks/acme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
ansible.builtin.user:
name: acme
state: present
groups: lbops,haproxy
append: yes

- name: Install acl package so ansible can run as an unprivilegd user
ansible.builtin.package:
Expand All @@ -17,14 +19,15 @@

- name: Install the acme.sh script
ansible.builtin.shell:
cmd: /opt/acmesh/acme.sh --install
cmd: sh /opt/acmesh/acme.sh --install
chdir: /opt/acmesh
creates: /home/acme/.acme.sh/acme.sh
become: true
become_user: acme

- name: Create the acme account
ansible.builtin.shell:
cmd: /home/acme/.acme.sh/acme.sh --register-account --eab-kid {{ haproxy_acme_eab_kid }} --eab-hmac-key {{ haproxy_acme_eab_hmac_key }} --server https://acme.sectigo.com/v2/GEANTOV
creates: /home/acme/.acme.sh/account.conf
creates: /home/acme/.acme.sh/ca/acme.sectigo.com/v2/GEANTOV/account.key
become: true
become_user: acme
37 changes: 26 additions & 11 deletions roles/haproxy/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,36 @@
---
- name: Include acme installation
ansible.builtin.include_tasks: acme.yml
when: haproxy_acme | bool
- name: Download HAProxy GPG key
ansible.builtin.get_url:
url: https://haproxy.debian.net/bernat.debian.org.gpg
dest: /etc/apt/trusted.gpg.d/haproxy.asc
mode: '0644'

- name: Create lbops group
ansible.builtin.group:
name: lbops
state: present
- name: Add HAProxy repository to sources list
ansible.builtin.copy:
dest: /etc/apt/sources.list.d/haproxy.list
content: |
deb http://haproxy.debian.net bookworm-backports-3.0 main
mode: '0644'

- name: Install haproxy and socat
ansible.builtin.apt:
name:
- haproxy
- haproxy=3.0.*
- socat
- git
state: present
register: haproxy_package_installed
until: haproxy_package_installed is succeeded

- name: Include acme installation
ansible.builtin.include_tasks: acme.yml
when: haproxy_acme | bool

- name: Create lbops group
ansible.builtin.group:
name: lbops
state: present

- name: Copy haproxy sysconfig file
ansible.builtin.copy:
src: sysconfig_haproxy
Expand Down Expand Up @@ -125,9 +139,6 @@
notify:
- "reload haproxy"

- name: include get_acme_certs
include_tasks: get_acme_certs.yml
when: haproxy_acme | bool and vhost_acls.changed

- name: Copy haproxy maps
ansible.builtin.template:
Expand Down Expand Up @@ -155,6 +166,10 @@
notify:
- "reload haproxy"

- name: include get_acme_certs
include_tasks: get_acme_certs.yml
when: haproxy_acme | bool and vhost_acls.changed

- name: Start and enable haproxy
ansible.builtin.service:
name: haproxy
Expand Down

0 comments on commit 821a93e

Please sign in to comment.