mirror of
https://github.com/iiab/iiab.git
synced 2025-03-09 15:40:17 +00:00
Merge remote-tracking branch 'cwivagg/cwivagg/matomo_20220430' into matomo
This commit is contained in:
commit
e48c688443
3 changed files with 179 additions and 0 deletions
|
@ -13,6 +13,11 @@
|
||||||
name: awstats
|
name: awstats
|
||||||
when: awstats_install
|
when: awstats_install
|
||||||
|
|
||||||
|
- name: MATOMO
|
||||||
|
include_role:
|
||||||
|
name: matomo
|
||||||
|
when: matomo_install
|
||||||
|
|
||||||
- name: MONIT
|
- name: MONIT
|
||||||
include_role:
|
include_role:
|
||||||
name: monit
|
name: monit
|
||||||
|
|
163
roles/matomo/tasks/install.yml
Normal file
163
roles/matomo/tasks/install.yml
Normal file
|
@ -0,0 +1,163 @@
|
||||||
|
# The sections of code interacting with the Matomo website are modified from code found at https://git.coop/webarch/matomo/. This code is distributed under
|
||||||
|
# Version 3 of the GNU General Public License. We modified this code and applied it here in April 2022. The derived sections correspond to the tasks running
|
||||||
|
# from "HTTP Get Welcome" through "Finish Matomo Setup", lines 29 through 126.
|
||||||
|
|
||||||
|
- name: Start MariaDB
|
||||||
|
action: service name=mysql state=started
|
||||||
|
- name: Create MariaDB Database for Matomo
|
||||||
|
community.mysql.mysql_db:
|
||||||
|
name: "{{ mdb_dbname }}"
|
||||||
|
state: present
|
||||||
|
login_unix_socket: /var/run/mysqld/mysqld.sock
|
||||||
|
- name: Add Admin User to MariaDB Database
|
||||||
|
community.mysql.mysql_user:
|
||||||
|
name: "{{ mdb_username }}"
|
||||||
|
password: "{{ mdb_password }}"
|
||||||
|
host: localhost
|
||||||
|
state: present
|
||||||
|
update_password: on_create
|
||||||
|
priv: "{{ mdb_dbname }}.*:ALL"
|
||||||
|
login_unix_socket: /var/run/mysqld/mysqld.sock
|
||||||
|
- name: Download and Extract Matomo
|
||||||
|
unarchive:
|
||||||
|
src: https://builds.matomo.org/matomo.zip
|
||||||
|
dest: "{{ nginx_loc }}"
|
||||||
|
remote_src: yes
|
||||||
|
- name: Set Matomo Directory Permissions
|
||||||
|
file:
|
||||||
|
path: "{{ nginx_loc }}/matomo"
|
||||||
|
recurse: yes
|
||||||
|
owner: www-data
|
||||||
|
group: www-data
|
||||||
|
- name: HTTP Get Welcome
|
||||||
|
uri:
|
||||||
|
url: "{{ matomo_url }}index.php?action=welcome"
|
||||||
|
method: GET
|
||||||
|
status_code: 200
|
||||||
|
register: matomo_welcome
|
||||||
|
- name: debug welcome
|
||||||
|
debug:
|
||||||
|
var: matomo_welcome
|
||||||
|
verbosity: 2
|
||||||
|
- name: Set a variable for the MATOMO_SESSID cookie
|
||||||
|
set_fact:
|
||||||
|
matomo_session_cookie: "MATOMO_SESSID={{ cookie.value }}"
|
||||||
|
when: cookie.key == "MATOMO_SESSID"
|
||||||
|
loop: "{{ matomo_welcome.cookies | dict2items }}"
|
||||||
|
loop_control:
|
||||||
|
loop_var: cookie
|
||||||
|
- name: Get Matomo System Check
|
||||||
|
uri:
|
||||||
|
url: "{{matomo_url}}index.php?action=systemCheck"
|
||||||
|
method: GET
|
||||||
|
headers:
|
||||||
|
Cookie: "{{ matomo_session_cookie }}"
|
||||||
|
return_content: true
|
||||||
|
timeout: 120
|
||||||
|
status_code: 200
|
||||||
|
register: matomo_system_check
|
||||||
|
- name: debug syscheck
|
||||||
|
debug:
|
||||||
|
var: matomo_system_check
|
||||||
|
verbosity: 2
|
||||||
|
- name: Matomo Database Setup
|
||||||
|
uri:
|
||||||
|
url: "{{ matomo_url }}index.php?action=databaseSetup"
|
||||||
|
method: POST
|
||||||
|
headers:
|
||||||
|
Cookie: "{{ matomo_session_cookie }}"
|
||||||
|
body:
|
||||||
|
username: "{{ mdb_username }}"
|
||||||
|
password: "{{ mdb_password }}"
|
||||||
|
dbname: "{{ mdb_dbname }}"
|
||||||
|
tables_prefix: "matomo_"
|
||||||
|
adapter: "PDO\\MYSQL"
|
||||||
|
body_format: form-urlencoded
|
||||||
|
status_code: 302
|
||||||
|
register: matomo_database_setup
|
||||||
|
- name: Matomo Table Creation
|
||||||
|
uri:
|
||||||
|
url: "{{ matomo_url }}index.php?action=tablesCreation&module=Installation"
|
||||||
|
method: GET
|
||||||
|
status_code: 200
|
||||||
|
register: matomo_table_creation
|
||||||
|
- name: Set a variable for the MATOMO_SESSID cookie
|
||||||
|
set_fact:
|
||||||
|
matomo_session_cookie: "MATOMO_SESSID={{ cookie.value }}"
|
||||||
|
when:
|
||||||
|
- matomo_table_creation.cookies is defined
|
||||||
|
- matomo_table_creation.cookies | length > 0
|
||||||
|
- cookie.key == "MATOMO_SESSID"
|
||||||
|
loop: "{{ matomo_table_creation.cookies | dict2items }}"
|
||||||
|
loop_control:
|
||||||
|
loop_var: cookie
|
||||||
|
- name: debug tablecreation
|
||||||
|
debug:
|
||||||
|
var: matomo_table_creation
|
||||||
|
verbosity: 2
|
||||||
|
- name: Matomo User Setup
|
||||||
|
uri:
|
||||||
|
url: "{{ matomo_url }}index.php?action=setupSuperUser&module=Installation"
|
||||||
|
method: POST
|
||||||
|
headers:
|
||||||
|
Cookie: "{{ matomo_session_cookie }}"
|
||||||
|
body:
|
||||||
|
login: "{{ mdb_username }}"
|
||||||
|
password: "{{ mdb_password }}"
|
||||||
|
password_bis: "{{ mdb_password }}"
|
||||||
|
email: "nobody@dev.null"
|
||||||
|
subscribe_newsletter_piwikorg: 0
|
||||||
|
subscribe_newsletter_professionalservices: 0
|
||||||
|
body_format: form-urlencoded
|
||||||
|
status_code: 302
|
||||||
|
register: matomo_setup_superuser
|
||||||
|
- name: Configure Matomo to track IIAB
|
||||||
|
uri:
|
||||||
|
url: "{{ matomo_url }}index.php?action=firstWebsiteSetup&module=Installation"
|
||||||
|
method: POST
|
||||||
|
headers:
|
||||||
|
Cookie: "{{ matomo_session_cookie }}"
|
||||||
|
body:
|
||||||
|
siteName: "IIAB"
|
||||||
|
url: "{{ host_url }}"
|
||||||
|
timezone: "Europe/London"
|
||||||
|
ecommerce: 0
|
||||||
|
body_format: form-urlencoded
|
||||||
|
status_code: 302
|
||||||
|
register: matomo_first_website_setup
|
||||||
|
- name: Matomo Tracking Code
|
||||||
|
uri:
|
||||||
|
url: "{{ matomo_url }}index.php?action=trackingCode&module=Installation&site_idSite=1&site_name={{ host_url }}"
|
||||||
|
method: GET
|
||||||
|
headers:
|
||||||
|
Cookie: "{{ matomo_session_cookie }}"
|
||||||
|
return_content: true
|
||||||
|
status_code: 200
|
||||||
|
register: matomo_tracking_code
|
||||||
|
- name: Finish Matomo Setup
|
||||||
|
uri:
|
||||||
|
url: "{{ matomo_url }}index.php?action=finished&module=Installation"
|
||||||
|
method: POST
|
||||||
|
headers:
|
||||||
|
Cookie: "{{ matomo_session_cookie }}"
|
||||||
|
body:
|
||||||
|
do_not_track: 1
|
||||||
|
anonymise_ip: 1
|
||||||
|
submit: "Continue to Matomo"
|
||||||
|
body_format: form-urlencoded
|
||||||
|
status_code: 302
|
||||||
|
- name: Start Collecting Matomo Data
|
||||||
|
cron:
|
||||||
|
name: "MatomoDataIngestionOnReboot"
|
||||||
|
special_time: reboot
|
||||||
|
job: "{{ matomo_cronjob }}"
|
||||||
|
user: root
|
||||||
|
cron_file: "matomo_reboot"
|
||||||
|
- name: Run Daily Job Collecting Matomo Data
|
||||||
|
cron:
|
||||||
|
name: "DailyMatomoDataIngestion"
|
||||||
|
minute: "0"
|
||||||
|
hour: "0"
|
||||||
|
job: "{{ matomo_cronjob }}"
|
||||||
|
user: root
|
||||||
|
cron_file: "matomo_daily"
|
11
roles/matomo/tasks/main.yml
Normal file
11
roles/matomo/tasks/main.yml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
- name: Install Matomo main
|
||||||
|
include_tasks: install.yml
|
||||||
|
when: matomo_installed is undefined
|
||||||
|
vars:
|
||||||
|
nginx_loc: "/library/www/html"
|
||||||
|
mdb_dbname: "matomodb"
|
||||||
|
mdb_username: "iiab-admin"
|
||||||
|
mdb_password: "g0adm1n"
|
||||||
|
host_url: "http://{{ ansible_default_ipv4.address}}"
|
||||||
|
matomo_url: "{{ host_url }}/matomo/"
|
||||||
|
matomo_cronjob: "sudo python3 /library/www/html/matomo/misc/log-analytics/import_logs.py --url={{ matomo_url }} --idsite=1 --recorders=4 --enable-http-errors --enable-http-redirects --enable-static --enable-bots /var/log/nginx/access.log"
|
Loading…
Add table
Add a link
Reference in a new issue