Skip to content

Commit 8d8a12c

Browse files
author
Miguel Medinilla
committed
Simplify SPOA release configuration
1 parent e1642d3 commit 8d8a12c

File tree

14 files changed

+445
-119
lines changed

14 files changed

+445
-119
lines changed

README.md

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,24 @@ required repositories configured.
5151
| Variable | Default | Description |
5252
| --- | --- | --- |
5353
| `haproxy_decision_manage_repo` | `true` | Toggle repository management. |
54-
| `haproxy_decision_haproxy_package` | `haproxy` | Package name used to install HAProxy. Override if you need a specific NEVRA. |
54+
| `haproxy_decision_haproxy_repo` | `artefactual-labs/haproxy-el-packaging` | GitHub repository hosting the HAProxy RPM release assets. |
55+
| `haproxy_decision_haproxy_version` | `2.8.16` | Release tag used to compose download URLs for HAProxy RPMs. |
56+
| `haproxy_decision_haproxy_release_number` | `1` | Packaging release identifier appended to the RPM name (e.g. `-1.el9`). |
57+
| `haproxy_decision_haproxy_rpm_arch` | `x86_64` | Architecture suffix used when deriving the default RPM filename. |
58+
| `haproxy_decision_haproxy_rpm` | `""` | Optional override for the full HAProxy RPM filename. Leave empty to derive `haproxy-<version>-<release>.el<major>.<arch>.rpm` automatically. |
59+
| `haproxy_decision_haproxy_checksums` | `{}` | Optional checksum map keyed by EL major version (e.g. `"9": "sha256:..."`). |
60+
| `haproxy_decision_spoa_releases` | see defaults | Mapping keyed by SPOA name (`decision`, `coraza`, `cookie_guard`) that exposes per-OS package URLs (`rh_package_url`, `debian_package_url`, or `package_urls.*`) plus optional checksum settings (`use_checksum`, `checksums_url`, `checksums`). Override entries to point at your own builds. |
61+
| `haproxy_decision_haproxy_package` | `haproxy` | (Debian/Ubuntu) Package name used with `apt`. Override if you need a specific NEVRA. |
5562
| `haproxy_decision_manage_config` | `true` | When `true` the role renders `haproxy.cfg` from `templates/haproxy.cfg.j2`. |
5663
| `haproxy_decision_global_settings` / `haproxy_decision_defaults_settings` | see defaults | Lists of directives written to the `global` and `defaults` sections. |
5764
| `haproxy_decision_listeners`, `haproxy_decision_frontends`, `haproxy_decision_backends` | `[]` | Optional lists of sections appended to the generated configuration. |
58-
| `haproxy_decision_spoas` | see defaults | Dictionary describing each SPOA daemon. Set `enabled: true` to activate one, and override `backend`, `env_opts`, or template-specific options as required. |
65+
| `haproxy_decision_spoas` | see defaults | Dictionary describing each SPOA daemon. Set `enabled: true` to activate one, adjust service/backend data, and rely on `haproxy_decision_spoa_releases` for download metadata when installing from GitHub releases. |
5966
| `haproxy_decision_manage_spoa_configs` | `true` | Controls whether the role writes SPOE configuration snippets. |
6067
| `haproxy_decision_manage_spoa_env` | `true` | Controls whether `/etc/default/*` files are managed for SPOAs. |
6168
| `haproxy_decision_manage_spoa_services` | `true` | Enable or disable service/timer management for SPOAs. |
6269
| `haproxy_decision_coraza_spoa_relax_systemd` | `false` | When `true` the role installs a systemd drop-in that removes the `BindReadOnlyPaths=-/etc/ld.so.cache` restriction from the `coraza-spoa` service. |
63-
| `haproxy_decision_release_url_template` | `https://github.com/{repo}/releases/download/{version}/{asset}` | Template used to compose download URLs for HAProxy RPM assets. Override when mirroring artifacts to a private host. The default asset map expects keys matching the OS major version (e.g. `"8"`, `"9"`). |
70+
| `haproxy_decision_release_url_template` | `https://github.com/{repo}/releases/download/{version}/{asset}` | Base template used to compose download URLs for GitHub releases. |
71+
| `haproxy_decision_haproxy_url_template` | `haproxy_decision_release_url_template` | Template applied to HAProxy downloads. Package entries may override it per release. |
6472
| `haproxy_decision_rhel_disable_gpg_check` | `false` | Disable RPM signature verification for HAProxy and SPOA downloads (useful in CI if upstream artifacts are unsigned). |
6573
| `haproxy_decision_spoa_release_url_template` | same as above | Base template used for SPOA downloads. Individual entries may override it with `haproxy_decision_spoas.<name>.release.url_template`. |
6674

@@ -115,9 +123,27 @@ Each SPOA definition accepts overrides that feed directly into the templates:
115123
- Override runtime arguments through `env_opts`.
116124
- Inject extra HAProxy directives with `spoa.backend.extra_lines` or
117125
`spoa.extra_config`.
126+
- Provide direct package URLs via `haproxy_decision_spoa_releases.<name>` when
127+
you need to source binaries from somewhere other than the defaults.
118128
- Supply additional messages or groups for the Cookie Guard SPOA using the
119129
`messages` or `group_definitions` structures.
120130

131+
Example release override:
132+
133+
```yaml
134+
haproxy_decision_spoa_releases:
135+
decision:
136+
rh_package_url: https://downloads.example.com/decision-spoa-1.2.3-2.el9.x86_64.rpm
137+
debian_package_url: https://downloads.example.com/decision-spoa_1.2.3_amd64.deb
138+
use_checksum: true
139+
checksums_url: https://downloads.example.com/decision-spoa-1.2.3.sha256
140+
```
141+
142+
Legacy overrides that supply `haproxy_decision_spoas.<name>.release.assets`
143+
still work, but migrating to the central `haproxy_decision_spoa_releases`
144+
structure keeps package metadata in a single place.
145+
```
146+
121147
If a more drastic change is required, point `config_template` or `env_template`
122148
to a custom template shipped alongside your playbook.
123149

defaults/main.yml

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,19 @@
22
haproxy_decision_manage_repo: true
33

44
haproxy_decision_rhel_download_dir: /var/cache/ansible/haproxy-decision
5-
haproxy_decision_haproxy_release:
6-
repo: artefactual-labs/haproxy-el-packaging
7-
version: "2.8.16"
8-
assets:
9-
"8": haproxy-2.8.16-1.el8.x86_64.rpm
10-
"9": haproxy-2.8.16-1.el9.x86_64.rpm
11-
checksums: {}
5+
haproxy_decision_haproxy_repo: artefactual-labs/haproxy-el-packaging
6+
haproxy_decision_haproxy_version: "2.8.16"
7+
haproxy_decision_haproxy_release_number: "1"
8+
haproxy_decision_haproxy_rpm: ""
9+
haproxy_decision_haproxy_rpm_arch: x86_64
10+
haproxy_decision_haproxy_checksums: {}
1211
haproxy_decision_rhel_disable_gpg_check: false
1312
haproxy_decision_release_url_template: "https://github.com/{repo}/releases/download/{version}/{asset}"
13+
haproxy_decision_haproxy_url_template: "{{ haproxy_decision_release_url_template }}"
14+
haproxy_decision_spoa_releases:
15+
decision: {}
16+
coraza: {}
17+
cookie_guard: {}
1418

1519
haproxy_decision_apt_repos: []
1620
haproxy_decision_ubuntu_repo: "ppa:vbernat/haproxy-2.8"
@@ -121,11 +125,6 @@ haproxy_decision_spoas:
121125
- "--metrics-host-label"
122126
config_template: spoa/decision-spoa.cfg.j2
123127
config_path: "{{ haproxy_decision_spoe_configs_dir }}/decision-spoa.cfg"
124-
release:
125-
repo: artefactual-labs/decision-spoa
126-
version: ""
127-
assets: {}
128-
checksums: {}
129128
backend:
130129
name: decision_spoa_backend
131130
balance: roundrobin
@@ -147,11 +146,6 @@ haproxy_decision_spoas:
147146
- "-config /etc/coraza-spoa/config.yaml"
148147
config_template: spoa/coraza-spoa.cfg.j2
149148
config_path: "{{ haproxy_decision_spoe_configs_dir }}/coraza-spoa.cfg"
150-
release:
151-
repo: artefactual-labs/coraza-spoa-crs-package
152-
version: ""
153-
assets: {}
154-
checksums: {}
155149
backend:
156150
name: coraza_spoa_backend
157151
balance: roundrobin
@@ -177,11 +171,6 @@ haproxy_decision_spoas:
177171
- "-expected-len 168"
178172
config_template: spoa/cookie-guard-spoa.cfg.j2
179173
config_path: "{{ haproxy_decision_spoe_configs_dir }}/cookie-guard-spoa.cfg"
180-
release:
181-
repo: artefactual-labs/cookie-guard-spoa
182-
version: ""
183-
assets: {}
184-
checksums: {}
185174
backend:
186175
name: cookie_guard_spoa_backend
187176
balance: roundrobin

tasks/config.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
owner: "{{ haproxy_decision_config_owner }}"
77
group: "{{ haproxy_decision_config_group }}"
88
mode: "0755"
9+
tags:
10+
- haproxy-decision
11+
- haproxy-decision-config
12+
- haproxy-decision-files
913

1014
- name: Ensure SPOE configuration directory exists
1115
ansible.builtin.file:
@@ -14,6 +18,10 @@
1418
owner: "{{ haproxy_decision_config_owner }}"
1519
group: "{{ haproxy_decision_config_group }}"
1620
mode: "0750"
21+
tags:
22+
- haproxy-decision
23+
- haproxy-decision-config
24+
- haproxy-decision-files
1725

1826
- name: Ensure HAProxy runtime directory exists
1927
ansible.builtin.file:
@@ -22,6 +30,10 @@
2230
owner: "{{ haproxy_decision_runtime_dir_owner }}"
2331
group: "{{ haproxy_decision_runtime_dir_group }}"
2432
mode: "{{ haproxy_decision_runtime_dir_mode }}"
33+
tags:
34+
- haproxy-decision
35+
- haproxy-decision-config
36+
- haproxy-decision-files
2537

2638
- name: Apply SELinux port labels for HAProxy
2739
community.general.seport:
@@ -35,6 +47,10 @@
3547
when:
3648
- haproxy_decision_selinux_port_labels | length > 0
3749
- ansible_selinux.status | default('disabled') == 'enabled'
50+
tags:
51+
- haproxy-decision
52+
- haproxy-decision-config
53+
- haproxy-decision-selinux
3854

3955
- name: Apply SELinux booleans for HAProxy
4056
ansible.posix.seboolean:
@@ -47,3 +63,7 @@
4763
when:
4864
- haproxy_decision_selinux_booleans | length > 0
4965
- ansible_selinux.status | default('disabled') == 'enabled'
66+
tags:
67+
- haproxy-decision
68+
- haproxy-decision-config
69+
- haproxy-decision-selinux

tasks/haproxy.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
- name: Ensure HAProxy binary has CAP_NET_BIND_SERVICE
22
become: true
33
when: haproxy_decision_setcap_net_bind_service | bool
4+
tags:
5+
- haproxy-decision
6+
- haproxy-decision-config
7+
- haproxy-decision-haproxy
48
block:
59
- name: Check HAProxy binary capabilities
610
ansible.builtin.command: "getcap {{ haproxy_decision_binary_path }}"
@@ -21,3 +25,7 @@
2125
mode: "{{ haproxy_decision_config_mode }}"
2226
when: haproxy_decision_manage_config | bool
2327
notify: reload haproxy
28+
tags:
29+
- haproxy-decision
30+
- haproxy-decision-config
31+
- haproxy-decision-haproxy

tasks/install-debian.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@
44
name: "{{ haproxy_decision_haproxy_package }}"
55
state: "{{ haproxy_decision_package_state }}"
66
register: haproxy_decision_package_result
7+
tags:
8+
- haproxy-decision
9+
- haproxy-decision-install
710

811
- name: Install additional HAProxy dependencies
912
ansible.builtin.package:
1013
name: "{{ haproxy_decision_extra_packages }}"
1114
state: "{{ haproxy_decision_package_state }}"
1215
when: haproxy_decision_extra_packages | length > 0
16+
tags:
17+
- haproxy-decision
18+
- haproxy-decision-install

tasks/install-redhat.yml

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,53 @@
1-
---
2-
- name: Determine HAProxy release asset for EL{{ haproxy_decision_rhel_major_version }}
1+
- name: Capture HAProxy RPM filename
32
ansible.builtin.set_fact:
4-
haproxy_decision_haproxy_asset: "{{ haproxy_decision_haproxy_release.assets[haproxy_decision_rhel_major_version] | default('') }}"
5-
6-
- name: Ensure HAProxy release asset is defined
7-
ansible.builtin.assert:
8-
that:
9-
- haproxy_decision_haproxy_asset | length > 0
10-
fail_msg: >-
11-
No HAProxy RPM asset configured for EL{{ haproxy_decision_rhel_major_version }}.
12-
Override haproxy_decision_haproxy_release.assets with the filename published in
13-
the haproxy-el-packaging release.
3+
haproxy_decision_haproxy_filename: "{{ haproxy_decision_haproxy_rpm_effective | trim }}"
4+
tags:
5+
- haproxy-decision
6+
- haproxy-decision-install
147

158
- name: Determine HAProxy release download URL
169
ansible.builtin.set_fact:
1710
haproxy_decision_haproxy_asset_url: >-
18-
{{ (haproxy_decision_haproxy_release.url_template
19-
| default(haproxy_decision_release_url_template))
20-
| replace('{repo}', haproxy_decision_haproxy_release.repo)
21-
| replace('{version}', haproxy_decision_haproxy_release.version)
22-
| replace('{asset}', haproxy_decision_haproxy_asset) }}
11+
{{
12+
(haproxy_decision_haproxy_url_template
13+
| replace('{repo}', haproxy_decision_haproxy_repo | trim)
14+
| replace('{version}', haproxy_decision_haproxy_version | trim)
15+
| replace('{asset}', haproxy_decision_haproxy_filename | trim)
16+
) | trim
17+
}}
18+
tags:
19+
- haproxy-decision
20+
- haproxy-decision-install
2321

2422
- name: Download HAProxy release artifact
2523
ansible.builtin.get_url:
2624
url: "{{ haproxy_decision_haproxy_asset_url }}"
27-
dest: "{{ haproxy_decision_rhel_download_dir }}/{{ haproxy_decision_haproxy_asset }}"
25+
dest: "{{ (haproxy_decision_rhel_download_dir ~ '/' ~ haproxy_decision_haproxy_filename) | trim }}"
2826
mode: "0644"
29-
checksum: "{{ haproxy_decision_haproxy_release.checksums[haproxy_decision_rhel_major_version] | default(omit) }}"
27+
checksum: "{{ haproxy_decision_haproxy_checksums[haproxy_decision_rhel_major_version] | default(omit) }}"
3028
register: haproxy_decision_haproxy_download
3129
retries: "{{ haproxy_decision_download_retries }}"
3230
delay: "{{ haproxy_decision_download_delay }}"
3331
until: haproxy_decision_haproxy_download is succeeded
32+
tags:
33+
- haproxy-decision
34+
- haproxy-decision-install
3435

3536
- name: Install HAProxy from downloaded RPM
3637
ansible.builtin.dnf:
37-
name: "{{ haproxy_decision_rhel_download_dir }}/{{ haproxy_decision_haproxy_asset }}"
38+
name: "{{ (haproxy_decision_rhel_download_dir ~ '/' ~ haproxy_decision_haproxy_filename) | trim }}"
3839
state: "{{ haproxy_decision_package_state }}"
3940
disable_gpg_check: "{{ haproxy_decision_rhel_disable_gpg_check | bool }}"
41+
tags:
42+
- haproxy-decision
43+
- haproxy-decision-install
4044

4145
- name: Install additional HAProxy dependencies
4246
ansible.builtin.dnf:
4347
name: "{{ haproxy_decision_extra_packages }}"
4448
state: "{{ haproxy_decision_package_state }}"
4549
disable_gpg_check: "{{ haproxy_decision_rhel_disable_gpg_check | bool }}"
4650
when: haproxy_decision_extra_packages | length > 0
51+
tags:
52+
- haproxy-decision
53+
- haproxy-decision-install

tasks/install.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
- name: Install HAProxy packages on Debian-based systems
33
ansible.builtin.include_tasks: install-debian.yml
44
when: ansible_os_family == "Debian"
5+
tags:
6+
- haproxy-decision
7+
- haproxy-decision-install
58

69
- name: Install HAProxy packages on Red Hat-based systems
710
ansible.builtin.include_tasks: install-redhat.yml
811
when: ansible_os_family == "RedHat"
12+
tags:
13+
- haproxy-decision
14+
- haproxy-decision-install

tasks/main.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,43 @@
66
fail_msg: >-
77
ansible-haproxy-decision only supports RedHat and Debian families.
88
Detected: {{ ansible_os_family }}
9+
tags:
10+
- haproxy-decision
11+
- haproxy-decision-verify
912

1013
- name: Include platform setup tasks
1114
ansible.builtin.include_tasks: "setup-{{ ansible_os_family | lower }}.yml"
15+
tags:
16+
- haproxy-decision
17+
- haproxy-decision-setup
1218

1319
- name: Install HAProxy packages
1420
ansible.builtin.include_tasks: install.yml
21+
tags:
22+
- haproxy-decision
23+
- haproxy-decision-install
1524

1625
- name: Prepare HAProxy layout and configuration files
1726
ansible.builtin.include_tasks: config.yml
27+
tags:
28+
- haproxy-decision
29+
- haproxy-decision-config
1830

1931
- name: Configure optional SPOA services
2032
ansible.builtin.include_tasks: spoa.yml
33+
tags:
34+
- haproxy-decision
35+
- haproxy-decision-spoa
2136

2237
- name: Render HAProxy configuration
2338
ansible.builtin.include_tasks: haproxy.yml
39+
tags:
40+
- haproxy-decision
41+
- haproxy-decision-config
42+
- haproxy-decision-haproxy
2443

2544
- name: Ensure services are enabled and running
2645
ansible.builtin.include_tasks: services.yml
46+
tags:
47+
- haproxy-decision
48+
- haproxy-decision-services

0 commit comments

Comments
 (0)