Guest User

Untitled

a guest
Sep 2nd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. # group_vars/{staging & production}/wordpress_sites.yml
  2. ...
  3. matomo:
  4. db:
  5. user: matomo
  6. host: localhost
  7.  
  8. # group_vars/{staging & production}/vault.yml
  9. ...
  10. matomo:
  11. db:
  12. password:
  13.  
  14. # server.yml
  15. ...
  16. - { role: matomo, tags: [matomo] }
  17.  
  18. # roles/matomo/defaults/main.yml
  19. combined_wordpress_sites: "{{ wordpress_sites|combine(vault_wordpress_sites, recursive=True) }}"
  20. addons_dir: "{{ www_root }}/{{ item.key }}/addons"
  21. matomo_db_name: "matomo_{{ env }}"
  22.  
  23. # roles/matomo/tasks/main.yml
  24. - name: Install Matomo
  25. composer:
  26. command: require
  27. arguments: piwik/piwik
  28. working_dir: "{{ addons_dir }}"
  29. with_dict: "{{ wordpress_sites }}"
  30. tags: matomo
  31.  
  32. - name: Create databases for Matomo
  33. mysql_db:
  34. name: "{{ matomo_db_name }}"
  35. state: present
  36. login_host: "{{ site_env.db_host }}"
  37. login_user: "{{ mysql_root_user }}"
  38. login_password: "{{ mysql_root_password }}"
  39. with_dict: "{{ wordpress_sites }}"
  40. tags: matomo
  41.  
  42. - name: Create/assign database user to db and grant permissions
  43. mysql_user:
  44. name: "{{ item.value.matomo.db.user }}"
  45. password: "{{ item.value.matomo.db.password }}"
  46. host: "{{ site_env.db_user_host }}"
  47. append_privs: yes
  48. priv: "{{ matomo_db_name }}.*:ALL"
  49. state: present
  50. login_host: "{{ site_env.db_host }}"
  51. login_user: "{{ mysql_root_user }}"
  52. login_password: "{{ mysql_root_password }}"
  53. with_dict: "{{ combined_wordpress_sites }}"
  54. tags: matomo
  55.  
  56. - name: Change addons owner to web_user
  57. file:
  58. path: "{{ addons_dir }}"
  59. owner: "{{ web_user }}"
  60. group: "{{ web_group }}"
  61. state: directory
  62. recurse: yes
  63. with_dict: "{{ wordpress_sites }}"
  64. tags: matomo
  65.  
  66.  
  67. - name: Explain next steps
  68. debug:
  69. msg: |
  70. If necessary, set up Matomo as follows.
  71. 1) Deploy
  72. 2) Point your browser to {{ wordpress_env_defaults.wp_home }}/analytics
  73. 3) Proceed with the form using following credentials:
  74. Host: {{ site_env.db_user_host }}
  75. Database: {{ matomo_db_name }}
  76. Database User: {{ item.value.matomo.db.user }}
  77. Database Password: {{ item.value.matomo.db.password }}
  78. Table Prefix: none
  79. Set up your admin user.
  80. 4) Log in to Matomo.
  81. 5) Under Administration/System/Geolocation, download and activate the GeoIP 2 database.
  82. with_dict: "{{ combined_wordpress_sites }}"
  83. tags: matomo
  84.  
  85. # roles/deploy/defaults/main.yml
  86. ...
  87. deploy_share_after:
  88. - "{{ playbook_dir }}/deploy-hooks/share-after.yml"
  89.  
  90. # deploy-hooks/share-after.yml
  91. - name: Create symlink to Matomo
  92. file:
  93. path: "{{ deploy_helper.new_release_path }}/web/analytics"
  94. src: "{{ addons_dir }}/vendor/piwik/piwik"
  95. state: link
  96. with_items: "{{ wordpress_sites }}"
Add Comment
Please, Sign In to add comment