Skip to content
Snippets Groups Projects
Commit c4e986cb authored by jurgenhaas's avatar jurgenhaas
Browse files

Rename piwik to matomo

parents
Branches
No related tags found
No related merge requests found
LICENSE 0 → 100644
The MIT License (MIT)
Copyright (c) 2015, 2016 Jürgen Haas, PARAGON Executive Services GmbH
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
matomo_version: '3.8.0'
matomo_force_reset: False
---
dependencies:
- { role: common, when: ignore_these_tasks is defined }
- { role: php }
- { role: letsencrypt }
---
# file: roles/matomo/tasks/apache.yml
- block:
- name: "Apache Configuration File"
template:
src='vhost.conf'
dest='/etc/apache2/sites-available/{{ matomo.domain }}{{ apache_conf_ext }}'
owner='root'
group='root'
mode='664'
notify:
- "Apache | Restart Apache"
- name: "Apache enable our new site(s)"
command: a2ensite {{ matomo.domain }} creates=/etc/apache2/sites-enabled/{{ matomo.domain }}{{ apache_conf_ext }}
notify:
- "Apache | Restart Apache"
- name: "Apache install GeoIP"
apt:
pkg: 'libapache2-mod-geoip'
state: 'present'
tags: 'ApacheConfig'
---
# file: roles/matomo/tasks/install.yml
- block:
- set_fact:
webRoot='/var/www/matomo/{{ matomo.id }}'
apacheUser='www-data'
apacheLogDir='/var/log/apache2'
when: matomo.jail is not defined
- set_fact:
webRoot='{{ jailroot }}/{{ matomo.id }}/var/www/matomo'
apacheUser='{{ matomo.id }}'
apacheLogDir='{{ jailroot }}/{{ matomo.id }}/var/log/apache2'
when: matomo.jail is defined
tags: 'always'
- name: "Configure Apache"
include_tasks: apache.yml
tags: 'ApacheConfig'
- name: "Remove existing components"
file:
path: '{{ item }}'
state: 'absent'
with_items:
- '{{ webRoot }}'
when: matomo_force_reset
tags: 'always'
- name: "Ensure Root Directories"
file:
path='{{ item }}'
state='directory'
owner='{{ apacheUser }}'
group='{{ apacheUser }}'
mode='775'
with_items:
- '{{ webRoot }}'
tags: 'always'
- name: "File Modes and Ownership"
file:
path='{{ webRoot }}'
owner='{{ apacheUser }}'
group='{{ apacheUser }}'
mode='g+w'
recurse=yes
follow=no
tags: 'deploy'
- name: "Clone Git Repository"
git:
accept_hostkey: yes
repo: 'git@github.com:matomo/matomo.git'
dest: '{{ webRoot }}'
track_submodules: yes
force: yes
version: '{{ matomo_version }}'
become: false
environment:
GIT_LFS_SKIP_SMUDGE: '1'
tags: 'deploy'
- name: "Configuration file"
template:
src='config.ini.php'
dest='{{ webRoot }}/config/config.ini.php'
owner='{{ apacheUser }}'
group='{{ apacheUser }}'
mode='664'
tags: 'deploy'
- name: "Composer"
composer:
command='update'
working_dir='{{ webRoot }}'
no_dev=yes
optimize_autoloader=yes
prefer_dist=yes
ignore_errors: true
tags: 'deploy'
- name: "Ensure Working Directories"
file:
path='{{ item }}'
state='directory'
owner='{{ apacheUser }}'
group='{{ apacheUser }}'
mode='775'
with_items:
- '{{ webRoot }}/tmp'
tags: 'always'
- name: "File Modes and Ownership"
file:
path='{{ webRoot }}'
owner='{{ apacheUser }}'
group='{{ apacheUser }}'
mode='a-w'
recurse=yes
follow=no
tags: 'deploy'
- name: "File Modes for .git Directory"
file:
path='{{ webRoot }}/.git'
mode='og+w'
recurse=yes
follow=no
tags: 'deploy'
- name: "File Modes for tmp"
file:
path='{{ webRoot }}/tmp'
mode='ug+w'
recurse=yes
follow=no
tags: 'deploy'
- name: "Ensure Database"
mysql_db:
name='matomo_{{ matomo.id }}'
login_user='root'
login_password='{{ mysql_root_password|default("root") }}'
login_host='127.0.0.1'
login_port='{{ matomo.db_port|default('3306') }}'
state='present'
- name: "Run Upgrade"
command: '{{ webRoot }}/console core:update --yes --no-interaction'
become_user: '{{ apacheUser }}'
ignore_errors: true
tags: 'deploy'
---
# file: roles/matomo/tasks/main.yml
- name: "matomo Role"
set_fact: role_matomo_started=true
tags: 'always'
- block:
- name: "Install Certs"
include_tasks: '../../letsencrypt/tasks/cert.yml'
with_items: '{{ matomo_settings|default([]) }}'
loop_control:
loop_var: domain
when: domain.protocol|default("https") == "https" and domain.letsencrypt|default(true)
tags: 'ApacheConfig'
when: '"letsencrypt" not in excluded_roles and groups.proxyserver is not defined'
- block:
- name: "Install matomo"
include_tasks: install.yml
with_items: '{{ matomo_settings|default([]) }}'
loop_control:
loop_var: matomo
when: limit_site is not defined or matomo.id is not defined or limit_site == matomo.id
tags:
- 'ApacheConfig'
- 'deploy'
when: '"matomo" not in excluded_roles'
; <?php exit; ?> DO NOT REMOVE THIS LINE
; file automatically generated or modified by matomo; you can manually override the default values in global.ini.php by redefining them in this file.
[database]
host = "127.0.0.1"
username = "root"
password = "{{ mysql_root_password|default("root") }}"
dbname = "matomo_{{ matomo.id }}"
tables_prefix = "matomo_"
port = "{{ matomo.db_port|default('3306') }}"
[General]
assume_secure_protocol = {% if matomo.protocol|default("https") == "https" %}1{% else %}0{% endif %}
trusted_hosts[] = "{{ matomo.domain }}"
salt = "{{ matomo.config.salt }}"
proxy_client_headers[] = "HTTP_X_FORWARDED_FOR"
proxy_host_headers[] = "HTTP_X_FORWARDED_HOST"
[mail]
transport = "smtp"
port = {{ matomo.smtp.port }}
host = "{{ matomo.smtp.host }}"
type = "{{ matomo.smtp.authtype }}"
username = "{{ matomo.smtp.name }}"
password = "{{ matomo.smtp.password }}"
{% if matomo.smtp.secure is defined %}
encryption = "{{ matomo.smtp.secure }}"
{% endif %}
[Plugins]
Plugins[] = "CorePluginsAdmin"
Plugins[] = "CoreAdminHome"
Plugins[] = "CoreHome"
Plugins[] = "WebsiteMeasurable"
Plugins[] = "Diagnostics"
Plugins[] = "CoreVisualizations"
Plugins[] = "Proxy"
Plugins[] = "API"
Plugins[] = "ExamplePlugin"
Plugins[] = "Widgetize"
Plugins[] = "Transitions"
Plugins[] = "LanguagesManager"
Plugins[] = "Actions"
Plugins[] = "Dashboard"
Plugins[] = "MultiSites"
Plugins[] = "Referrers"
Plugins[] = "DevicesDetection"
Plugins[] = "Goals"
Plugins[] = "SEO"
Plugins[] = "Events"
Plugins[] = "UserCountry"
Plugins[] = "VisitsSummary"
Plugins[] = "VisitFrequency"
Plugins[] = "VisitTime"
Plugins[] = "VisitorInterest"
Plugins[] = "ExampleAPI"
Plugins[] = "Feedback"
Plugins[] = "Login"
Plugins[] = "UsersManager"
Plugins[] = "SitesManager"
Plugins[] = "Installation"
Plugins[] = "CoreUpdater"
Plugins[] = "CoreConsole"
Plugins[] = "ScheduledReports"
Plugins[] = "UserCountryMap"
Plugins[] = "Live"
Plugins[] = "CustomVariables"
Plugins[] = "PrivacyManager"
Plugins[] = "ImageGraph"
Plugins[] = "Annotations"
Plugins[] = "MobileMessaging"
Plugins[] = "Overlay"
Plugins[] = "SegmentEditor"
Plugins[] = "Morpheus"
Plugins[] = "Contents"
Plugins[] = "BulkTracking"
Plugins[] = "Resolution"
Plugins[] = "DevicePlugins"
Plugins[] = "Intl"
Plugins[] = "Marketplace"
Plugins[] = "Provider"
Plugins[] = "DoNotTrack"
Plugins[] = "SecurityInfo"
[PluginsInstalled]
PluginsInstalled[] = "Login"
PluginsInstalled[] = "CoreAdminHome"
PluginsInstalled[] = "UsersManager"
PluginsInstalled[] = "SitesManager"
PluginsInstalled[] = "Installation"
PluginsInstalled[] = "CorePluginsAdmin"
PluginsInstalled[] = "CoreHome"
PluginsInstalled[] = "Proxy"
PluginsInstalled[] = "API"
PluginsInstalled[] = "Widgetize"
PluginsInstalled[] = "Transitions"
PluginsInstalled[] = "LanguagesManager"
PluginsInstalled[] = "Actions"
PluginsInstalled[] = "Dashboard"
PluginsInstalled[] = "MultiSites"
PluginsInstalled[] = "Goals"
PluginsInstalled[] = "SEO"
PluginsInstalled[] = "UserCountry"
PluginsInstalled[] = "VisitsSummary"
PluginsInstalled[] = "VisitFrequency"
PluginsInstalled[] = "VisitTime"
PluginsInstalled[] = "VisitorInterest"
PluginsInstalled[] = "ExampleAPI"
PluginsInstalled[] = "ExamplePlugin"
PluginsInstalled[] = "ExampleRssWidget"
PluginsInstalled[] = "Provider"
PluginsInstalled[] = "Feedback"
PluginsInstalled[] = "CoreUpdater"
PluginsInstalled[] = "UserCountryMap"
PluginsInstalled[] = "Live"
PluginsInstalled[] = "CustomVariables"
PluginsInstalled[] = "PrivacyManager"
PluginsInstalled[] = "ImageGraph"
PluginsInstalled[] = "DoNotTrack"
PluginsInstalled[] = "Annotations"
PluginsInstalled[] = "MobileMessaging"
PluginsInstalled[] = "Overlay"
PluginsInstalled[] = "SegmentEditor"
PluginsInstalled[] = "AnonymizeIP"
PluginsInstalled[] = "CoreConsole"
PluginsInstalled[] = "CoreVisualizations"
PluginsInstalled[] = "Referrers"
PluginsInstalled[] = "ScheduledReports"
PluginsInstalled[] = "Events"
PluginsInstalled[] = "Morpheus"
PluginsInstalled[] = "DevicesDetection"
PluginsInstalled[] = "ZenMode"
PluginsInstalled[] = "LeftMenu"
PluginsInstalled[] = "Contents"
PluginsInstalled[] = "BulkTracking"
PluginsInstalled[] = "Resolution"
PluginsInstalled[] = "DevicePlugins"
PluginsInstalled[] = "WebsiteMeasurable"
PluginsInstalled[] = "Diagnostics"
PluginsInstalled[] = "Intl"
PluginsInstalled[] = "Marketplace"
PluginsInstalled[] = "SecurityInfo"
email = {{ apache_server_admin|default('admin@paragon-es.de') }}
domains = {{ cert.domain }}{% for alias in cert.aliases|default([]) %}, {{ alias }}{% endfor %}{% for trusted_domain in cert.trusted_domains|default([]) %}, {{ trusted_domain }}{% endfor %}
text = True
{% if groups.proxyserver is defined and inventory_hostname in groups.proxyserver %}
authenticator = standalone
{% endif %}
# standalone-supported-challenges = tls-sni-01
agree-tos = True
expand = True
keep-until-expiring = True
<VirtualHost *:80>
Include /etc/apache2/{{ apache_conf_dir }}/global-redirect.conf
{% if matomo.protocol|default("https") == "https" and groups.proxyserver is not defined %}
ServerAdmin {{ apache_server_admin }}
ServerName {{ matomo.domain }}
ServerAlias {{ matomo.domain }}{% for alias in matomo.aliases|default([]) %} {{ alias }}{% endfor %}
Include /etc/apache2/{{ apache_conf_dir }}/redirect-ssl.conf
Include /etc/apache2/{{ apache_conf_dir }}/letsencrypt-redirect.conf
SetEnvIf X-Forwarded-For "^.*\..*\..*\..*" forwarded
LogLevel warn
{% if apache_version|default('2.4') == '2.4' %}
ErrorLogFormat "[%{u}t] [%l] [pid %P] [client\ %{X-Forwarded-For}i] %M% ,\ referer:\ %{Referer}i"
{% endif %}
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" proxy
ErrorLog {{ apacheLogDir }}/{{ matomo.domain }}-error.log
CustomLog {{ apacheLogDir }}/{{ matomo.domain }}-access.log combined env=!forwarded
CustomLog {{ apacheLogDir }}/{{ matomo.domain }}-access.log proxy env=forwarded
</VirtualHost>
<VirtualHost *:443>
Include /etc/apache2/{{ apache_conf_dir }}/global-redirect.conf
{% endif %}
ServerAdmin {{ apache_server_admin }}
ServerName {{ matomo.domain }}
ServerAlias {{ matomo.domain }}{% for alias in matomo.aliases|default([]) %} {{ alias }}{% endfor %}
Header always add Strict-Transport-Security "max-age=15768000; includeSubDomains; preload"
{% if matomo.jail is defined and not php_fpm_socket|default(false) %}
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:{{ matomo.jail.port }}/$1
{% endif %}
DocumentRoot {{ webRoot }}
<Directory {{ webRoot }}/>
Options +ExecCGI +Indexes +FollowSymLinks +MultiViews
AllowOverride All
{% if apache_version|default('2.4') == '2.2' %}
Order allow,deny
allow from all
{% else %}
Include /etc/apache2/{{ apache_conf_dir }}/global-deny.conf
{% endif %}
</Directory>
<Directory {{ webRoot }}/.git/>
Require all denied
</Directory>
<IfModule mod_geoip.c>
GeoIPEnable On
GeoIPDBFile /usr/share/GeoIP/GeoIP.dat
</IfModule>
SetEnvIf X-Forwarded-For "^.*\..*\..*\..*" forwarded
LogLevel warn
{% if apache_version|default('2.4') == '2.4' %}
ErrorLogFormat "[%{u}t] [%l] [pid %P] [client\ %{X-Forwarded-For}i] %M% ,\ referer:\ %{Referer}i"
{% endif %}
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" proxy
ErrorLog {{ apacheLogDir }}/{{ matomo.domain }}-error.log
CustomLog {{ apacheLogDir }}/{{ matomo.domain }}-access.log combined env=!forwarded
CustomLog {{ apacheLogDir }}/{{ matomo.domain }}-access.log proxy env=forwarded
<IfModule mod_expires.c>
ExpiresActive {% if apache_cache.active %}On{% else %}Off{% endif %}
ExpiresDefault {{ apache_cache.default }}
{% for type in apache_cache.bytype %}
ExpiresByType {{ type.type }} {{ type.default }}
{% endfor %}
</IfModule>
SetEnvIf X-Forwarded-Proto https HTTPS=on
BrowserMatch "MSIE [2-6]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
# MSIE 7 and newer should be able to use keepalive
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
{% if matomo.protocol|default("https") == "https" and groups.proxyserver is not defined %}
Include /etc/apache2/{{ apache_conf_dir }}/options-ssl-apache.conf
{% if matomo.letsencrypt|default(true) %}
SSLCertificateFile /etc/letsencrypt/live/{{ matomo.domain }}/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/{{ matomo.domain }}/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/{{ matomo.domain }}/chain.pem
{% else %}
{% for certs in apache_certificates|default([]) %}
{% if certs.domain == matomo.domain %}
{% for cert in certs.certs %}
{{cert.type}} /etc/ssl/private/{{cert.file}}
{% endfor %}
{% for alias in certs.aliases|default([]) %}
</VirtualHost>
<VirtualHost *:443>
Include /etc/apache2/{{ apache_conf_dir }}/global-redirect.conf
ServerName {{ alias }}
Redirect 301 / https://{{ certs.domain }}/
SSLEngine on
{% for cert in certs.certs %}
{{cert.type}} /etc/ssl/private/{{cert.file}}
{% endfor %}
SetEnvIf X-Forwarded-For "^.*\..*\..*\..*" forwarded
LogLevel warn
{% if apache_version|default('2.4') == '2.4' %}
ErrorLogFormat "[%{u}t] [%l] [pid %P] [client\ %{X-Forwarded-For}i] %M% ,\ referer:\ %{Referer}i"
{% endif %}
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" proxy
ErrorLog {{ apacheLogDir }}/{{ certs.domain }}-error.log
CustomLog {{ apacheLogDir }}/{{ certs.domain }}-access.log combined env=!forwarded
CustomLog {{ apacheLogDir }}/{{ certs.domain }}-access.log proxy env=forwarded
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}
{% endif %}
</VirtualHost>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment