2016-07-05 18:29:03 +02:00
|
|
|
---
|
|
|
|
- block:
|
|
|
|
|
|
|
|
- name: Install the keepalived repository
|
|
|
|
apt_repository: repo={{ keepalived_repo }}
|
|
|
|
|
|
|
|
- name: Install the keepalived package
|
|
|
|
apt: name={{ item }} state={{ keepalived_pkg_state }} update_cache=yes
|
|
|
|
with_items: '{{ keepalived_pkgs }}'
|
|
|
|
|
|
|
|
- name: Install the keepalived configuration
|
|
|
|
template: src=keepalived.conf.j2 dest=/etc/keepalived/keepalived.conf
|
|
|
|
notify: restart keepalived
|
|
|
|
|
2016-08-08 18:18:41 +02:00
|
|
|
- name: Install the keepalived notify scripts
|
|
|
|
template: src=keepalived_notify.sh.j2 dest={{ item.notify }} owner=root group=root mode=0754
|
|
|
|
with_items: '{{ keepalived_instances }}'
|
|
|
|
|
|
|
|
- name: Install the keepalived NRPE nagios check
|
|
|
|
copy: src=check_keepalived_state dest={{ nagios_plugins_dir }}/check_keepalived_state owner=root group=root mode=0555
|
|
|
|
with_items: '{{ keepalived_instances }}'
|
|
|
|
when: keepalived_nagios_check
|
|
|
|
|
|
|
|
- name: Install the keepalived NRPE command configuration
|
|
|
|
template: src=keepalived-nrpe.cfg.j2 dest={{ nrpe_include_dir }}/keepalived-nrpe.cfg owner=root group=root mode=0444
|
|
|
|
notify: Reload NRPE server
|
|
|
|
when: keepalived_nagios_check
|
|
|
|
|
2016-07-05 18:29:03 +02:00
|
|
|
- name: Ensure that keepalived is started and enabled
|
|
|
|
service: name=keepalived state=started enabled=yes
|
|
|
|
when: keepalived_enabled
|
|
|
|
|
|
|
|
- name: Ensure that keepalived is stopped and disabled
|
|
|
|
service: name=keepalived state=stopped enabled=no
|
|
|
|
when: not keepalived_enabled
|
|
|
|
|
|
|
|
tags: keepalived
|
|
|
|
when: keepalived_install
|
|
|
|
|
|
|
|
|
|
|
|
- block:
|
|
|
|
|
|
|
|
- name: Remove the keepalived package if we do not want it
|
|
|
|
apt: name={{ item }} state=absent
|
|
|
|
with_items: '{{ keepalived_pkgs }}'
|
|
|
|
|
2016-08-08 18:18:41 +02:00
|
|
|
- name: Remove the keepalived notify scripts
|
|
|
|
file: dest={{ item.notify }} state=absent
|
|
|
|
with_items: '{{ keepalived_instances }}'
|
|
|
|
|
|
|
|
- name: Remove the keepalived NRPE check
|
|
|
|
file: dest={{ nagios_plugins_dir }}/check_keepalived_state state=absent
|
|
|
|
with_items: '{{ keepalived_instances }}'
|
|
|
|
|
|
|
|
- name: Remove the keepalived NRPE command configuration
|
|
|
|
file: dest={{ nrpe_include_dir }}/keepalived-nrpe.cfg state=absent
|
|
|
|
notify: Reload NRPE server
|
|
|
|
|
2016-07-05 18:29:03 +02:00
|
|
|
tags: keepalived
|
|
|
|
when: not keepalived_install
|
|
|
|
|