deploy_haproxy/tasks/install_host.yml
Bertrand Lanson db446aba16
All checks were successful
test / Linting (push) Successful in 8s
test / Molecule tests (default, ubuntu2004) (push) Successful in 1m16s
test / Molecule tests (default, debian11) (push) Successful in 1m30s
test / Molecule tests (default, debian12) (push) Successful in 1m30s
test / Molecule tests (default, ubuntu2204) (push) Successful in 1m15s
test / Molecule tests (with_tls_enabled, debian11) (push) Successful in 1m7s
test / Molecule tests (with_tls_enabled, debian12) (push) Successful in 1m14s
test / Molecule tests (with_tls_enabled, ubuntu2004) (push) Successful in 1m24s
test / Molecule tests (with_tls_enabled, ubuntu2204) (push) Successful in 1m35s
feat(core): change namespace and update dependencies
2024-02-07 21:20:13 +01:00

46 lines
1.6 KiB
YAML

---
# task/install_host file for deploy_haproxy
- name: "Configure haproxy repository"
ansible.builtin.include_role:
name: ednz_cloud.manage_repositories
vars:
manage_repositories_enable_default_repo: false
manage_repositories_enable_custom_repo: true
manage_repositories_custom_repo: "{{ deploy_haproxy_repository[ansible_distribution|lower] }}"
- 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'
- 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"