Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # group_vars/{staging & production}/wordpress_sites.yml
- ...
- matomo:
- db:
- user: matomo
- host: localhost
- # group_vars/{staging & production}/vault.yml
- ...
- matomo:
- db:
- password:
- # server.yml
- ...
- - { role: matomo, tags: [matomo] }
- # roles/matomo/defaults/main.yml
- combined_wordpress_sites: "{{ wordpress_sites|combine(vault_wordpress_sites, recursive=True) }}"
- addons_dir: "{{ www_root }}/{{ item.key }}/addons"
- matomo_db_name: "matomo_{{ env }}"
- # roles/matomo/tasks/main.yml
- - name: Install Matomo
- composer:
- command: require
- arguments: piwik/piwik
- working_dir: "{{ addons_dir }}"
- with_dict: "{{ wordpress_sites }}"
- tags: matomo
- - name: Create databases for Matomo
- mysql_db:
- name: "{{ matomo_db_name }}"
- state: present
- login_host: "{{ site_env.db_host }}"
- login_user: "{{ mysql_root_user }}"
- login_password: "{{ mysql_root_password }}"
- with_dict: "{{ wordpress_sites }}"
- tags: matomo
- - name: Create/assign database user to db and grant permissions
- mysql_user:
- name: "{{ item.value.matomo.db.user }}"
- password: "{{ item.value.matomo.db.password }}"
- host: "{{ site_env.db_user_host }}"
- append_privs: yes
- priv: "{{ matomo_db_name }}.*:ALL"
- state: present
- login_host: "{{ site_env.db_host }}"
- login_user: "{{ mysql_root_user }}"
- login_password: "{{ mysql_root_password }}"
- with_dict: "{{ combined_wordpress_sites }}"
- tags: matomo
- - name: Change addons owner to web_user
- file:
- path: "{{ addons_dir }}"
- owner: "{{ web_user }}"
- group: "{{ web_group }}"
- state: directory
- recurse: yes
- with_dict: "{{ wordpress_sites }}"
- tags: matomo
- - name: Explain next steps
- debug:
- msg: |
- If necessary, set up Matomo as follows.
- 1) Deploy
- 2) Point your browser to {{ wordpress_env_defaults.wp_home }}/analytics
- 3) Proceed with the form using following credentials:
- Host: {{ site_env.db_user_host }}
- Database: {{ matomo_db_name }}
- Database User: {{ item.value.matomo.db.user }}
- Database Password: {{ item.value.matomo.db.password }}
- Table Prefix: none
- Set up your admin user.
- 4) Log in to Matomo.
- 5) Under Administration/System/Geolocation, download and activate the GeoIP 2 database.
- with_dict: "{{ combined_wordpress_sites }}"
- tags: matomo
- # roles/deploy/defaults/main.yml
- ...
- deploy_share_after:
- - "{{ playbook_dir }}/deploy-hooks/share-after.yml"
- # deploy-hooks/share-after.yml
- - name: Create symlink to Matomo
- file:
- path: "{{ deploy_helper.new_release_path }}/web/analytics"
- src: "{{ addons_dir }}/vendor/piwik/piwik"
- state: link
- with_items: "{{ wordpress_sites }}"
Add Comment
Please, Sign In to add comment