---
- name: Install keepalived
  apt:
    update_cache: true
    name: keepalived
  register: apt_result
  retries: 3
  until: apt_result is succeeded

- name: Deploy keepalived configuration
  template:
    src: keepalived/keepalived.conf.j2
    dest: /etc/keepalived/keepalived.conf
    mode: 0644
  notify: Reload keepalived.service

- name: Create scripts directory
  file:
    path: /usr/scripts
    state: directory

- name: Deploy keepalived dhcp scripts
  template:
    src: bin/notify-dhcp
    dest: /usr/scripts/notify-dhcp
    mode: 0744
  when: not ansible_check_mode
  notify: Reload keepalived.service