diff --git a/group_vars/all/00_general.yml b/group_vars/all/00_general.yml index e05a8cdd..ea2aa49b 100644 --- a/group_vars/all/00_general.yml +++ b/group_vars/all/00_general.yml @@ -17,6 +17,7 @@ HOST_DECIMAL_MARK: "," deployment_mode: "single" # Use single, if you deploy on one server. Use cluster if you setup in cluster mode. web_protocol: "https" # Web protocol type. Use https or http. If you run local you need to change it to http +web_port: "{{ 443 if web_protocol == 'https' else 80 }}" # Default port web applications will listen to ## Domain primary_domain_tld: "localhost" # Top Level Domain of the server diff --git a/roles/docker-compose/handlers/main.yml b/roles/docker-compose/handlers/main.yml index 73244334..5d3a0221 100644 --- a/roles/docker-compose/handlers/main.yml +++ b/roles/docker-compose/handlers/main.yml @@ -7,7 +7,17 @@ COMPOSE_HTTP_TIMEOUT: 600 DOCKER_CLIENT_TIMEOUT: 600 -# default setup for docker compose files +- name: Validate Docker Compose configuration + command: + cmd: docker compose -f {{ docker_compose.files.docker_compose }} config --quiet + chdir: "{{ docker_compose.directories.instance }}" + register: dc_validate + changed_when: false + failed_when: dc_validate.rc != 0 + listen: + - docker compose up + - docker compose restart + - name: docker compose up shell: docker-compose -p {{ application_id }} up -d --force-recreate --remove-orphans --build args: diff --git a/roles/svc-rdbms-central/tasks/main.yml b/roles/svc-rdbms-central/tasks/main.yml index ee3145e5..77fc8ea2 100644 --- a/roles/svc-rdbms-central/tasks/main.yml +++ b/roles/svc-rdbms-central/tasks/main.yml @@ -24,7 +24,7 @@ - name: "Create central database" include_role: - name: "web-app-{{database_type}}" + name: "svc-rdbms-{{database_type}}" when: applications | is_feature_enabled('central_database',application_id) - name: "Add database to backup" diff --git a/roles/web-app-matomo/tasks/constructor.yml b/roles/web-app-matomo/tasks/constructor.yml new file mode 100644 index 00000000..8c13d405 --- /dev/null +++ b/roles/web-app-matomo/tasks/constructor.yml @@ -0,0 +1,51 @@ +- name: "include svc-rdbms-central" + include_role: + name: svc-rdbms-central + +- name: "include role srv-web-proxy-domain for {{application_id}}" + include_role: + name: srv-web-proxy-domain + vars: + domain: "{{ domains | get_domain(application_id) }}" + http_port: "{{ ports.localhost.http[application_id] }}" + +- name: flush docker service + meta: flush_handlers + +# Wait for API +- name: Exclude global IPs in Matomo + uri: + url: "{{ matomo_index_php_url }}" + method: POST + body_format: form-urlencoded + body: + module: API + method: SitesManager.setGlobalExcludedIps + excludedIps: "{{ matomo_excluded_ips | join(',') }}" + format: json + token_auth: "{{ matomo_auth_token }}" + return_content: yes + status_code: 200 + register: matomo_exclude + until: matomo_exclude.status == 200 + retries: 5 + delay: 10 + +- name: Exclude CSP-CheckerBot user agent in Matomo + uri: + url: "{{ matomo_index_php_url }}" + method: POST + body_format: form-urlencoded + body: + module: API + method: SitesManager.setGlobalExcludedUserAgents + excludedUserAgents: "CSP-CheckerBot" + format: json + token_auth: "{{ matomo_auth_token }}" + return_content: yes + status_code: 200 + +- name: run the docker matomo tasks once + set_fact: + run_once_web_app_matomo: true + when: run_once_web_app_matomo is not defined diff --git a/roles/web-app-matomo/tasks/main.yml b/roles/web-app-matomo/tasks/main.yml index d560ea66..b48d4260 100644 --- a/roles/web-app-matomo/tasks/main.yml +++ b/roles/web-app-matomo/tasks/main.yml @@ -1,46 +1,5 @@ --- -- name: "include svc-rdbms-central" - include_role: - name: svc-rdbms-central - when: run_once_docker_matomo is not defined +- name: "construct {{ role_name }}" + include_tasks: constructor.yml + when: run_once_web_app_matomo is not defined -- name: "include role srv-web-proxy-domain for {{application_id}}" - include_role: - name: srv-web-proxy-domain - vars: - domain: "{{ domains | get_domain(application_id) }}" - http_port: "{{ ports.localhost.http[application_id] }}" - when: run_once_docker_matomo is not defined - -- name: run the docker matomo tasks once - set_fact: - run_once_docker_matomo: true - when: run_once_docker_matomo is not defined - -- name: Exclude global IPs in Matomo - uri: - url: "{{ matomo_index_php_url }}" - method: POST - body_format: form-urlencoded - body: - module: API - method: SitesManager.setGlobalExcludedIps - excludedIps: "{{ matomo_excluded_ips | join(',') }}" - format: json - token_auth: "{{ matomo_auth_token }}" - return_content: yes - status_code: 200 - -- name: Exclude CSP-CheckerBot user agent in Matomo - uri: - url: "{{ matomo_index_php_url }}" - method: POST - body_format: form-urlencoded - body: - module: API - method: SitesManager.setGlobalExcludedUserAgents - excludedUserAgents: "CSP-CheckerBot" - format: json - token_auth: "{{ matomo_auth_token }}" - return_content: yes - status_code: 200