ansible-roles/haproxy/tasks/haproxy-service.yml

48 lines
1.4 KiB
YAML

---
- name: Get the haproxy repo key
apt_key: url=http://haproxy.debian.net/bernat.debian.org.gpg state=present
when: haproxy_latest_release
register: haproxy_repo
tags: haproxy
- name: Define the haproxy repository
apt_repository: repo='{{ haproxy_latest_repo }}' state=present update_cache=yes
when: haproxy_latest_release
register: haproxy_repo
tags: haproxy
- name: Install the haproxy package
apt: name=haproxy state=present default_release={{ ansible_lsb.codename }}-backports
when: not haproxy_latest_release
tags: haproxy
- name: Install the haproxy package
apt: name=haproxy state=latest default_release={{ ansible_lsb.codename }}-backports-{{ haproxy_version }}
when:
- haproxy_latest_release
- is_debian
tags: haproxy
- name: Install the haproxy package
apt: name=haproxy state=latest
when:
- haproxy_latest_release
- is_ubuntu
tags: haproxy
- name: Ensure that haproxy is enabled and started
service: name=haproxy state=restarted enabled=yes
when: haproxy_enabled
ignore_errors: True
tags: haproxy
- name: Haproxy puts a new rsyslog directive. Restart rsyslog to activate it. Reload is not sufficient
service: name=rsyslog state=restarted
when: haproxy_enabled
tags: haproxy
- name: Ensure that haproxy is stopped and disabled if needed
service: name=haproxy state=stopped enabled=no
when: not haproxy_enabled
tags: haproxy