|
| 1 | +--- |
| 2 | +- name: Install required PHP extensions for Matomo |
| 3 | + apt: |
| 4 | + name: "{{ item }}" |
| 5 | + state: present |
| 6 | + with_items: "{{ matomo_php_extensions }}" |
| 7 | + notify: restart php{{ php_version }}-fpm |
| 8 | + |
| 9 | +- name: Create addons folder for Matomo installation |
| 10 | + file: |
| 11 | + path: "{{ addons_dir }}" |
| 12 | + owner: "{{ web_user }}" |
| 13 | + group: "{{ web_group }}" |
| 14 | + mode: '0755' |
| 15 | + state: directory |
| 16 | + |
| 17 | +- name: Download Matomo |
| 18 | + get_url: |
| 19 | + url: "{{ matomo_url }}" |
| 20 | + dest: "/tmp/matomo_latest.zip" |
| 21 | + |
| 22 | +- name: Unzip Matomo |
| 23 | + unarchive: |
| 24 | + src: "/tmp/matomo_latest.zip" |
| 25 | + dest: "{{ addons_dir }}" |
| 26 | + remote_src: yes |
| 27 | + creates: "{{ addons_dir }}/matomo" |
| 28 | + |
| 29 | +- name: Set ownership of Matomo files |
| 30 | + file: |
| 31 | + path: "{{ addons_dir }}/matomo" |
| 32 | + owner: "{{ matomo_owner }}" |
| 33 | + group: "{{ matomo_group }}" |
| 34 | + recurse: yes |
| 35 | + |
| 36 | +- name: Ensure correct permissions on Matomo directory |
| 37 | + file: |
| 38 | + path: "{{ addons_dir }}/matomo" |
| 39 | + mode: '0755' |
| 40 | + recurse: yes |
| 41 | + |
| 42 | +- name: Create Matomo database |
| 43 | + mysql_db: |
| 44 | + name: "{{ matomo_db_name }}" |
| 45 | + state: present |
| 46 | + login_host: "{{ site_env.db_host }}" |
| 47 | + login_user: "{{ mysql_root_user }}" |
| 48 | + login_password: "{{ mysql_root_password }}" |
| 49 | + with_dict: "{{ wordpress_sites }}" |
| 50 | + tags: matomo |
| 51 | + |
| 52 | +- name: Create Matomo database user and grant permissions |
| 53 | + mysql_user: |
| 54 | + name: "{{ item.value.matomo.db.user }}" |
| 55 | + password: "{{ item.value.matomo.db.password }}" |
| 56 | + host: "{{ site_env.db_user_host }}" |
| 57 | + append_privs: yes |
| 58 | + priv: "{{ matomo_db_name }}.*:ALL" |
| 59 | + state: present |
| 60 | + login_host: "{{ site_env.db_host }}" |
| 61 | + login_user: "{{ mysql_root_user }}" |
| 62 | + login_password: "{{ mysql_root_password }}" |
| 63 | + with_dict: "{{ wordpress_sites }}" |
| 64 | + tags: matomo |
| 65 | + |
| 66 | +- name: Create symlink to Matomo |
| 67 | + file: |
| 68 | + path: "{{ deploy_helper.new_release_path }}/web/analytics" |
| 69 | + src: "{{ addons_dir }}/matomo" |
| 70 | + state: link |
| 71 | + with_dict: "{{ wordpress_sites }}" |
| 72 | + tags: matomo |
| 73 | + |
| 74 | +- name: Explain next steps |
| 75 | + debug: |
| 76 | + msg: | |
| 77 | + If necessary, set up Matomo as follows: |
| 78 | + 1) Deploy |
| 79 | + 2) Point your browser to {{ wordpress_env_defaults.wp_home }}/analytics |
| 80 | + 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. |
| 87 | + 4) Log in to Matomo. |
| 88 | + 5) Under Administration/System/Geolocation, download and activate the GeoIP 2 database. |
| 89 | + with_dict: "{{ wordpress_sites }}" |
| 90 | + tags: matomo |
0 commit comments