---
# file: roles/haproxy/tasks/install.yml

- name: "Add Apt Repositories"
  apt_repository:
    repo='{{ item }}'
    state=present
    mode='644'
  with_items:
    - "ppa:vbernat/haproxy-1.8"

- name: "Install some packages"
  apt:
    pkg='{{ item }}'
    state=latest
  with_items:
    - haproxy
    - hatop
    - socat

- name: "create directories"
  file:
    dest='{{ item }}'
    state=directory
    mode='755'
  with_items:
    - /etc/haproxy/certs
    - /etc/haproxy/update

- name: "Install hatop shortcut"
  copy:
    src='usr_local_bin_hatop'
    dest='/usr/local/bin/hatop'
    owner='root'
    group='root'
    mode='755'

- name: "Install log rotator"
  copy:
    src='etc_logrotate_d_haproxy'
    dest='/etc/logrotate.d/haproxy'
    owner='root'
    group='root'
    mode='644'
  tags: 'logrotate'

- name: "Install script to read socket"
  template:
    src='hasocket'
    dest='/usr/local/bin/hasocket'
    owner='root'
    group='root'
    mode='755'
