mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-29 15:06:26 +02:00
Renamed injection services
This commit is contained in:
66
roles/sys-srv-web-inj-matomo/tasks/main.yml
Normal file
66
roles/sys-srv-web-inj-matomo/tasks/main.yml
Normal file
@@ -0,0 +1,66 @@
|
||||
- block:
|
||||
- name: Include dependency 'srv-web-7-4-core'
|
||||
include_role:
|
||||
name: srv-web-7-4-core
|
||||
when: run_once_srv_web_7_4_core is not defined
|
||||
- include_tasks: utils/run_once.yml
|
||||
when: run_once_sys_srv_web_inj_matomo is not defined
|
||||
|
||||
- name: "Relevant variables for role: {{ role_path | basename }}"
|
||||
debug:
|
||||
msg:
|
||||
domain: "{{ domain }}"
|
||||
base_domain: "{{ base_domain }}"
|
||||
matomo_verification_url: "{{ matomo_verification_url }}"
|
||||
when: MODE_DEBUG | bool
|
||||
|
||||
- name: "Check if site {{ domain }} is allready registered at Matomo"
|
||||
uri:
|
||||
url: "{{ matomo_verification_url }}"
|
||||
method: GET
|
||||
return_content: yes
|
||||
status_code: 200
|
||||
validate_certs: yes
|
||||
register: site_check
|
||||
|
||||
- name: Set matomo_site_id to Null
|
||||
set_fact:
|
||||
matomo_site_id:
|
||||
|
||||
- name: Set fact for site ID if site already exists
|
||||
set_fact:
|
||||
matomo_site_id: "{{ site_check.json[0].idsite }}"
|
||||
when: "(site_check.json | length) > 0"
|
||||
changed_when: false
|
||||
|
||||
- name: Add site to Matomo and get ID if not exists
|
||||
uri:
|
||||
url: "{{ matomo_index_php_url }}"
|
||||
method: POST
|
||||
body: "module=API&method=SitesManager.addSite&siteName={{ base_domain }}&urls={{ WEB_PROTOCOL }}://{{ base_domain }}&token_auth={{ matomo_auth_token }}&format=json"
|
||||
body_format: form-urlencoded
|
||||
status_code: 200
|
||||
return_content: yes
|
||||
validate_certs: yes
|
||||
register: add_site
|
||||
when: "matomo_site_id is not defined or matomo_site_id is none"
|
||||
|
||||
- name: Set fact for site ID if site was added
|
||||
set_fact:
|
||||
matomo_site_id: "{{ add_site.json.value }}"
|
||||
when: "matomo_site_id is not defined or matomo_site_id is none"
|
||||
changed_when: false
|
||||
|
||||
- name: Load Matomo tracking JS template
|
||||
set_fact:
|
||||
matomo_tracking_code: "{{ lookup('template','matomo-tracking.js.j2') }}"
|
||||
|
||||
- name: Collapse Matomo code into one-liner
|
||||
set_fact:
|
||||
matomo_tracking_code_one_liner: "{{ matomo_tracking_code | to_one_liner }}"
|
||||
|
||||
- name: Append Matomo CSP hash
|
||||
set_fact:
|
||||
applications: "{{ applications | append_csp_hash(application_id, matomo_tracking_code_one_liner) }}"
|
||||
no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"
|
||||
changed_when: false
|
Reference in New Issue
Block a user