2024-01-30 22:20:26 +00:00
|
|
|
---
|
|
|
|
# task/install_host file for deploy_haproxy
|
|
|
|
- name: "Configure haproxy repository"
|
|
|
|
ansible.builtin.include_role:
|
2024-02-07 20:20:13 +00:00
|
|
|
name: ednz_cloud.manage_repositories
|
2024-01-30 22:20:26 +00:00
|
|
|
vars:
|
|
|
|
manage_repositories_enable_default_repo: false
|
|
|
|
manage_repositories_enable_custom_repo: true
|
|
|
|
manage_repositories_custom_repo: "{{ deploy_haproxy_repository[ansible_distribution|lower] }}"
|
2024-01-31 16:38:13 +00:00
|
|
|
|
|
|
|
- name: "Get service haproxy"
|
|
|
|
ansible.builtin.service_facts:
|
|
|
|
|
|
|
|
- name: "Install from repostories"
|
|
|
|
throttle: 1
|
|
|
|
block:
|
|
|
|
- name: "Install haproxy version: {{ deploy_haproxy_version }}"
|
|
|
|
ansible.builtin.apt:
|
|
|
|
update_cache: yes
|
|
|
|
name: "haproxy{{ '='~deploy_haproxy_version~'*' if deploy_haproxy_version != 'latest' }}"
|
|
|
|
state: "{{ 'present' if deploy_haproxy_version != 'latest' else deploy_haproxy_version}}"
|
|
|
|
allow_downgrade: true
|
|
|
|
cache_valid_time: 3600
|
|
|
|
|
|
|
|
- name: "Ensure haproxy is running"
|
|
|
|
ansible.builtin.service:
|
|
|
|
name: "{{ deploy_haproxy_service_name }}"
|
|
|
|
state: started
|
|
|
|
register: _haproxy_service_health
|
|
|
|
until: _haproxy_service_health.status.ActiveState == "active"
|
|
|
|
retries: 15
|
|
|
|
delay: 2
|
|
|
|
when:
|
|
|
|
ansible_facts.services[deploy_haproxy_service_name~'.service'] is defined
|
|
|
|
and ansible_facts.services[deploy_haproxy_service_name~'.service']['state'] == 'running'
|
2024-01-31 20:01:49 +00:00
|
|
|
|
|
|
|
- name: "Copy systemd service file for haproxy"
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: "haproxy.service.j2"
|
|
|
|
dest: "/etc/systemd/system/haproxy.service"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: "0644"
|
|
|
|
notify:
|
|
|
|
- "systemctl-daemon-reload"
|