haproxy: simplify versions tracking

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

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