---

- name: Configure monitoring for vhost
  template:
    src: http.j2
    dest: /etc/icinga2/conf.d/hosts/{{ inventory_hostname }}.http_{{ vhost }}
    owner: "{{ icinga_user }}"
    group: "{{ icinga_group }}"
  delegate_to: "{{ icinga_server }}"

- name: Regenerate hosts.conf
  assemble:
    src: /etc/icinga2/conf.d/hosts
    dest: /etc/icinga2/conf.d/hosts.conf
#   validate: /usr/sbin/icinga2 daemon -c %s --validate
  notify: Restart icinga2
  delegate_to: "{{ icinga_server }}"