feat(install): make haproxy usersystem user, ensure haproxy stays up if upgraded in bulk
This commit is contained in:
parent
782cc8d878
commit
97676d6485
@ -1,7 +1,7 @@
|
||||
---
|
||||
# defaults file for deploy_haproxy
|
||||
deploy_haproxy_deploy_method: host # deployment method, either host or docker
|
||||
deploy_haproxy_version: latest
|
||||
deploy_haproxy_version: "2.6"
|
||||
|
||||
# Options from the "default" config block in haproxy.cfg
|
||||
# The default values here are usually set, but you can change any of them.
|
||||
|
@ -7,3 +7,29 @@
|
||||
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'
|
||||
|
@ -15,6 +15,7 @@
|
||||
home: "{{ deploy_haproxy_chroot }}"
|
||||
create_home: false
|
||||
shell: /bin/false
|
||||
system: true
|
||||
state: present
|
||||
|
||||
- name: "Create directory {{ deploy_haproxy_config_dir }}"
|
||||
|
@ -5,6 +5,8 @@ deploy_haproxy_socket: /var/lib/haproxy/stats
|
||||
deploy_haproxy_chroot: /var/lib/haproxy
|
||||
deploy_haproxy_user: haproxy
|
||||
deploy_haproxy_group: haproxy
|
||||
deploy_haproxy_service_name: "haproxy{{ '_container' if deploy_haproxy_deploy_method == 'docker' }}"
|
||||
deploy_haproxy_docker_image: haproxy
|
||||
deploy_haproxy_version_map:
|
||||
latest: "2.9"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user