haproxy: simplify versions tracking

This commit is contained in:
ace 2024-05-16 18:20:18 +03:00
parent 3c8cb19285
commit d6457d12da
Signed by: ace
GPG Key ID: 2C08973DD37A76FD
12 changed files with 31 additions and 68 deletions

View File

@ -1,3 +1,4 @@
haproxy_version: ""
haproxy_path: /etc/haproxy
haproxy_ssl: no
haproxy_ssl_path: "{{ haproxy_path }}/ssl"

View File

@ -4,11 +4,13 @@
name: "{{ haproxy_unit_name }}"
state: reloaded
daemon_reload: yes
when: haproxy_enable_and_start.changed
masked: no
when: not haproxy_enable_and_start.changed
- name: Restart HAProxy
systemd:
name: "{{ haproxy_unit_name }}"
state: reloaded
state: restarted
daemon_reload: yes
when: haproxy_enable_and_start.changed
masked: no
when: not haproxy_enable_and_start.changed

View File

@ -18,28 +18,27 @@
ansible.builtin.systemd:
name: "{{ haproxy_unit_name }}"
masked: yes
when: haproxy_package_name not in ansible_facts.packages or ansible_facts.packages[haproxy_package_name][0]['version'] != (haproxy_version|string + "-" + haproxy_version_build|string)
changed_when: false
- name: "Install {{ haproxy_package_name }}-{{ haproxy_version }}-{{ haproxy_version_build }}"
- name: "Install {{ haproxy_package }}"
apt:
name: "{{ haproxy_package }}"
state: "{{ 'latest' if haproxy_version == 'latest' else 'present' }}"
update_cache: yes
register: haproxy_setup
when: haproxy_package_name not in ansible_facts.packages
notify:
- Restart HAProxy
- name: "Update {{ haproxy_package_name }}-{{ haproxy_version }}-{{ haproxy_version_build }}"
apt:
name: "{{ haproxy_package }}"
update_cache: yes
register: haproxy_update
notify: Restart HAProxy
when:
- haproxy_package_name in ansible_facts.packages
- ansible_facts.packages[haproxy_package_name][0]['version'] != (haproxy_version|string + "-" + haproxy_version_build|string)
- name: Unmask HAProxy after install
ansible.builtin.systemd:
name: "{{ haproxy_unit_name }}"
masked: no
changed_when: false
- name: Install python3-cryptography
package:
name: python3-cryptography
name: python3-cryptography
state: present
- block:
- name: Check net.ipv4.ip_nonlocal_bind

View File

@ -14,22 +14,14 @@
verbosity: 2
when: haproxy_installed_package is defined
- name: "Install {{ haproxy_package_name }}-{{ haproxy_version }}-{{ haproxy_version_build }}"
- name: "Install {{ haproxy_package }}"
dnf:
name: "{{ haproxy_package }}"
state: "{{ 'latest' if haproxy_version == 'latest' else 'present' }}"
update_cache: yes
register: haproxy_setup
when: haproxy_package_name not in ansible_facts.packages
- name: "Update {{ haproxy_package_name }}-{{ haproxy_version }}-{{ haproxy_version_build }}"
dnf:
name: "{{ haproxy_package }}"
update_cache: yes
register: haproxy_update
notify: Restart HAProxy
when:
- haproxy_package_name in ansible_facts.packages
- (ansible_facts.packages[haproxy_package_name][0]['version'] + ".el" + ansible_distribution_major_version) != (haproxy_version|string + "-" + haproxy_version_build|string)
notify:
- Restart HAProxy
- name: Install python2-cryptography
package:
@ -44,7 +36,7 @@
name: python3-cryptography
when:
- ansible_facts['os_family'] == 'RedHat'
- ansible_facts['distribution_major_version'] == '8' or ansible_facts['distribution_major_version'] == '9'
- ansible_facts['distribution_major_version'] > '8'
- haproxy_self_signed_cert
- name: Set haproxy_connect_any flag on and keep it persistent across reboots
@ -131,7 +123,7 @@
- name: Enable and start HAProxy service
systemd:
name: haproxy
name: "{{ haproxy_unit_name }}"
state: started
enabled: yes
daemon_reload: yes

View File

@ -1,6 +0,0 @@
haproxy_package_name: "haproxy"
haproxy_version: "2.6.12"
haproxy_version_build: "1~bpo11+1"
haproxy_package: "{{ haproxy_package_name }}={{ haproxy_version }}-{{ haproxy_version_build }}"
haproxy_package_name_regex: "{{ haproxy_package_name }}-{{ haproxy_version }}-{{ haproxy_version_build }}"
haproxy_unit_name: "{{ haproxy_package_name }}"

View File

@ -1,6 +0,0 @@
haproxy_package_name: "haproxy"
haproxy_version: "2.6.12"
haproxy_version_build: "1+deb12u1"
haproxy_package: "{{ haproxy_package_name }}={{ haproxy_version }}-{{ haproxy_version_build }}"
haproxy_package_name_regex: "{{ haproxy_package_name }}-{{ haproxy_version }}-{{ haproxy_version_build }}"
haproxy_unit_name: "{{ haproxy_package_name }}"

3
vars/Debian.yaml Normal file
View File

@ -0,0 +1,3 @@
haproxy_package_name: "haproxy"
haproxy_package: "{{ haproxy_package_name + '=' + haproxy_version if (haproxy_version is defined and (haproxy_version != 'latest' and haproxy_version != '*' and haproxy_version != '')) else haproxy_package_name }}"
haproxy_unit_name: "{{ haproxy_package_name }}"

View File

@ -1,7 +0,0 @@
haproxy_package_name: "haproxy"
haproxy_version: "1.8.27"
haproxy_version_build: "5.el{{ ansible_distribution_major_version }}"
haproxy_package: "{{ haproxy_package_name }}-{{ haproxy_version }}-{{ haproxy_version_build }}"
haproxy_package_name_regex: "{{ haproxy_package_name }}-{{ haproxy_version }}-{{ haproxy_version_build }}"
haproxy_unit_name: "{{ haproxy_package_name }}"

View File

@ -1,7 +0,0 @@
haproxy_package_name: "haproxy"
haproxy_version: "2.4.22"
haproxy_version_build: "3.el{{ ansible_distribution_major_version }}"
haproxy_package: "{{ haproxy_package_name }}-{{ haproxy_version }}-{{ haproxy_version_build }}"
haproxy_package_name_regex: "{{ haproxy_package_name }}-{{ haproxy_version }}-{{ haproxy_version_build }}"
haproxy_unit_name: "{{ haproxy_package_name }}"

4
vars/RedHat.yaml Normal file
View File

@ -0,0 +1,4 @@
haproxy_package_name: "haproxy"
haproxy_package: "{{ haproxy_package_name + '-' + haproxy_version if (haproxy_version is defined and (haproxy_version != 'latest' and haproxy_version != '*' and haproxy_version != '')) else haproxy_package_name }}"
haproxy_unit_name: "{{ haproxy_package_name }}"

View File

@ -1,6 +0,0 @@
haproxy_package_name: "haproxy"
haproxy_version: "2.0.33"
haproxy_version_build: "0ubuntu0.1"
haproxy_package: "{{ haproxy_package_name }}={{ haproxy_version }}-{{ haproxy_version_build }}"
haproxy_package_name_regex: "{{ haproxy_package_name }}-{{ haproxy_version }}-{{ haproxy_version_build }}"
haproxy_unit_name: "{{ haproxy_package_name }}"

View File

@ -1,6 +0,0 @@
haproxy_package_name: "haproxy"
haproxy_version: "2.4.24"
haproxy_version_build: "0ubuntu0.22.04.1"
haproxy_package: "{{ haproxy_package_name }}={{ haproxy_version }}-{{ haproxy_version_build }}"
haproxy_package_name_regex: "{{ haproxy_package_name }}-{{ haproxy_version }}-{{ haproxy_version_build }}"
haproxy_unit_name: "{{ haproxy_package_name }}"