|
6 | 6 | with_items: "{{ matomo_php_extensions }}"
|
7 | 7 | notify: reload php-fpm
|
8 | 8 |
|
| 9 | +- name: Install PyMySQL |
| 10 | + apt: |
| 11 | + name: python3-pymysql |
| 12 | + state: present |
| 13 | + become: yes |
| 14 | + |
9 | 15 | - name: Create addons folder for Matomo installation
|
10 | 16 | file:
|
11 | 17 | path: "{{ addons_dir }}"
|
12 | 18 | owner: "{{ web_user }}"
|
13 | 19 | group: "{{ web_group }}"
|
14 | 20 | mode: '0755'
|
15 | 21 | state: directory
|
| 22 | + with_dict: "{{ wordpress_sites }}" |
| 23 | + no_log: true |
16 | 24 |
|
17 | 25 | - name: Download Matomo
|
18 | 26 | get_url:
|
|
24 | 32 | src: "/tmp/matomo_latest.zip"
|
25 | 33 | dest: "{{ addons_dir }}"
|
26 | 34 | remote_src: yes
|
27 |
| - creates: "{{ addons_dir }}/matomo" |
| 35 | + creates: "{{ addons_dir }}/{{ matomo_dir }}" |
| 36 | + with_dict: "{{ wordpress_sites }}" |
| 37 | + no_log: true |
| 38 | + tags: matomo |
| 39 | + |
| 40 | +- name: Delete the unzipped "How to install Matomo.html" file |
| 41 | + file: |
| 42 | + path: "{{ addons_dir }}/How to install Matomo.html" |
| 43 | + state: absent |
| 44 | + with_dict: "{{ wordpress_sites }}" |
| 45 | + no_log: true |
| 46 | + tags: matomo |
28 | 47 |
|
29 | 48 | - name: Set ownership of Matomo files
|
30 | 49 | file:
|
31 |
| - path: "{{ addons_dir }}/matomo" |
| 50 | + path: "{{ addons_dir }}/{{ matomo_dir }}" |
32 | 51 | owner: "{{ matomo_owner }}"
|
33 | 52 | group: "{{ matomo_group }}"
|
34 | 53 | recurse: yes
|
| 54 | + with_dict: "{{ wordpress_sites }}" |
| 55 | + no_log: true |
| 56 | + tags: matomo |
35 | 57 |
|
36 | 58 | - name: Ensure correct permissions on Matomo directory
|
37 | 59 | file:
|
38 |
| - path: "{{ addons_dir }}/matomo" |
| 60 | + path: "{{ addons_dir }}/{{ matomo_dir }}" |
39 | 61 | mode: '0755'
|
40 | 62 | recurse: yes
|
| 63 | + with_dict: "{{ wordpress_sites }}" |
| 64 | + no_log: true |
| 65 | + tags: matomo |
| 66 | + |
| 67 | +- name: Check if Matomo variables are set for each site |
| 68 | + fail: |
| 69 | + msg: "Matomo database credentials are not set in your group_vars – please review and ensure these are configured for the site {{ item.key }}." |
| 70 | + when: |
| 71 | + - item.value.matomo is not defined |
| 72 | + - item.value.matomo.db is not defined |
| 73 | + - item.value.matomo.db.user is not defined or item.value.matomo.db.password is not defined |
| 74 | + with_dict: "{{ combined_wordpress_sites }}" |
| 75 | + no_log: true |
| 76 | + tags: matomo |
41 | 77 |
|
42 | 78 | - name: Create Matomo database
|
43 | 79 | mysql_db:
|
|
47 | 83 | login_user: "{{ mysql_root_user }}"
|
48 | 84 | login_password: "{{ mysql_root_password }}"
|
49 | 85 | with_dict: "{{ wordpress_sites }}"
|
| 86 | + no_log: true |
50 | 87 | tags: matomo
|
51 | 88 |
|
52 | 89 | - name: Create Matomo database user and grant permissions
|
|
60 | 97 | login_host: "{{ site_env.db_host }}"
|
61 | 98 | login_user: "{{ mysql_root_user }}"
|
62 | 99 | login_password: "{{ mysql_root_password }}"
|
63 |
| - with_dict: "{{ wordpress_sites }}" |
| 100 | + column_case_sensitive: true |
| 101 | + with_dict: "{{ combined_wordpress_sites }}" |
| 102 | + no_log: true |
64 | 103 | tags: matomo
|
65 | 104 |
|
66 | 105 | - name: Create symlink to Matomo
|
67 | 106 | file:
|
68 |
| - path: "{{ deploy_helper.new_release_path }}/web/analytics" |
69 |
| - src: "{{ addons_dir }}/matomo" |
| 107 | + path: "{{ www_root }}/{{ item.key }}/{{ item.value.current_path | default('current') }}/{{ item.value.public_path | default('web') }}/{{ item.value.matomo.path | default('matomo') }}" |
| 108 | + src: "{{ addons_dir }}/{{ matomo_dir }}" |
70 | 109 | state: link
|
71 |
| - with_dict: "{{ wordpress_sites }}" |
72 |
| - tags: matomo |
| 110 | + loop: "{{ wordpress_sites | dict2items }}" |
| 111 | + loop_control: |
| 112 | + label: "{{ item.key }}" |
73 | 113 |
|
74 | 114 | - name: Explain next steps
|
75 |
| - debug: |
76 |
| - msg: | |
| 115 | + pause: |
| 116 | + seconds: 0 |
| 117 | + prompt: | |
| 118 | + ====================== |
77 | 119 | If necessary, set up Matomo as follows:
|
| 120 | +
|
78 | 121 | 1) Deploy
|
79 |
| - 2) Point your browser to {{ wordpress_env_defaults.wp_home }}/analytics |
| 122 | +
|
| 123 | + 2) Point your browser to {{ wordpress_env_defaults.wp_home }}/{{ item.value.matomo.path | default('matomo') }} |
| 124 | +
|
80 | 125 | 3) Proceed with the form using following credentials:
|
81 |
| - Host: {{ site_env.db_user_host }} |
82 |
| - Database User: {{ item.value.matomo.db.user }} |
83 |
| - Database Password: {{ item.value.matomo.db.password }} |
84 |
| - Database: {{ matomo_db_name }} |
85 |
| - Table Prefix: none |
86 |
| - Set up your admin user. |
| 126 | + |
| 127 | + Host: {{ site_env.db_user_host }} |
| 128 | + Database User: {{ item.value.matomo.db.user }} |
| 129 | + Database Password: {{ item.value.matomo.db.password }} |
| 130 | + Database: {{ matomo_db_name }} |
| 131 | + Table Prefix: none |
| 132 | + Database Engine: MariaDB |
| 133 | + |
| 134 | + Set up your admin user. |
| 135 | +
|
87 | 136 | 4) Log in to Matomo.
|
| 137 | +
|
88 | 138 | 5) Under Administration/System/Geolocation, download and activate the GeoIP 2 database.
|
89 |
| - with_dict: "{{ wordpress_sites }}" |
| 139 | + ====================== |
| 140 | + with_dict: "{{ combined_wordpress_sites }}" |
| 141 | + no_log: true |
90 | 142 | tags: matomo
|
0 commit comments