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

- name: "HaProxy Role"
  set_fact: role_haproxy_started=true
  tags: always

- block:

  - name: "Install Certs"
    include: '../../letsencrypt/tasks/cert.yml'
    with_items: '{{ proxy_certificates_letsencrypt|default([]) }}'
    loop_control:
      loop_var: domain

  - name: "Renew Existing Cert"
    include: '../../letsencrypt/tasks/renew.yml'

  - name: "Build HaCerts"
    include: 'buildcerts.yml'

  tags: Certs
  when: '"letsencrypt" not in excluded_roles'

- block:

  - include: install.yml
  - include: configure.yml
    tags: Config

  when: '"haproxy" not in excluded_roles'
