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

- name: matomo Role
  set_fact:
    role_matomo_started: yes
  tags:
    - always

- block:
  - name: Install Certs
    include_tasks: ../../letsencrypt/tasks/cert.yml
    with_items: '{{ matomo_settings|default([]) }}'
    loop_control:
      loop_var: domain
    when: domain.protocol|default("https") == "https" and domain.letsencrypt|default(true)
    tags:
      - ApacheConfig

  when: not excluded_roles or "letsencrypt" not in excluded_roles and groups.proxyserver is not defined

- block:
  - name: Install matomo
    include_tasks: install.yml
    with_items: '{{ matomo_settings|default([]) }}'
    loop_control:
      loop_var: matomo
    when: limit_site is not defined or limit_site == 'no' or matomo.id is not defined or limit_site == matomo.id
    tags:
      - ApacheConfig
      - deploy

  when: not excluded_roles or "matomo" not in excluded_roles