---
- name: Install Heartbeat
  apt:
    pkg: heartbeat
    state: present

- name: Include OpenStack specific tasks
  include: openstack.yml
  when: IS_TARGET_OPENSTACK

- name: Configure Heartbeat
  template:
    src: hb_ha.cf.j2
    dest: /etc/heartbeat/ha.cf
    owner: root
    group: root
    mode: 0640
  notify: restart heartbeat

- name: Configure Heartbeat Resources
  template:
    src: hb_haresources.j2
    dest: /etc/heartbeat/haresources
    owner: root
    group: root
    mode: 0640
  notify: restart heartbeat
  when: configure_resources

- name: Configure Heartbeat Auth
  template:
    src: hb_authkeys.j2
    dest: /etc/heartbeat/authkeys
    owner: root
    group: root
    mode: 0600
  notify: restart heartbeat

---
- name: Install Heartbeat
  apt:
    pkg: heartbeat
    state: present

- name: Include OpenStack specific tasks
  include: openstack.yml
  when: IS_TARGET_OPENSTACK

- name: Stop Heartbeat resources for configuration
  service:
    name: heartbeat
    state: stopped
  notify: restart heartbeat

- name: Configure Heartbeat
  template:
    src: hb_ha.cf.j2
    dest: /etc/heartbeat/ha.cf
    owner: root
    group: root
    mode: 0640
  notify: restart heartbeat

- name: Configure Heartbeat Resources
  template:
    src: hb_haresources.j2
    dest: /etc/heartbeat/haresources
    owner: root
    group: root
    mode: 0640
  notify: restart heartbeat
  when: configure_resources

- name: Configure Heartbeat Auth
  template:
    src: hb_authkeys.j2
    dest: /etc/heartbeat/authkeys
    owner: root
    group: root
    mode: 0600
  notify: restart heartbeat

Stop heartbeat resources prior to configuration.
Stop heartbeat resources prior to configuration.
