ansible-piwik is an Ansible role. The playbook contains tasks to provide a Piwik installation (with MySQL backend) running on Nginx.
This fork replaces Apache with Nginx.
- MySQL
- Nginx
- PHP
- Latest Piwik codebase
- GeoIP database
- Ansible 1.4 or higher
- Debian 7.3 (other deb-based distros should work too) (this fork is tested on Ubuntu only)
- Vagrant (optional)
(If necessary adjust firewall rules to allow http...)
$ git clone [email protected]:weluse/ansible-piwik.git
Following example makes Ansible aware of a box reachable through SSH on 127.0.0.1, port 2222.
$ vi ansible.host
with
[piwik]
127.0.0.1 ansible_ssh_port=2222
---
- name: Piwik
hosts: piwik
roles:
- ansible-piwik
Create a host_vars or group_vars directory where the ansible.host file is located.
$ mkdir group_vars
Create the file piwik in the newly created directory.
$ cd group_vars
$ vi piwik
with
---
piwik:
mysql:
host: 127.0.0.1
admin_user: root
admin_pass: NEW
piwik_user: piwik
piwik_pass: piwik
piwik_db: piwik
webserver:
server_name: '<your server>'
settings:
ip_range: '192.168.33.1'
If empty the role will load default variables from defaults/main.yml
Make sure to use the Ansible setting hash_behaviour=merge in ansible.cfg, i.e.:
[defaults]
hash_behaviour=merge
Use ansible.host as inventory. Run the playbook only for the remote host piwik. Use vagrant as the SSH user to connect to the remote host. -k enables the SSH password prompt.
$ ansible-playbook -k -i ansible.host piwik.yml -u vagrant
SSH password:
PLAY [Piwik] ******************************************************************
GATHERING FACTS ***************************************************************
ok: [127.0.0.1]
TASK: [ansible-piwik | Install MySQL dependencies] ****************************
changed: [127.0.0.1] => (item=mysql-server)
changed: [127.0.0.1] => (item=python-mysqldb)
TASK: [ansible-piwik | Install PHP dependencies] ******************************
changed: [127.0.0.1] => (item=apache2)
changed: [127.0.0.1] => (item=php5)
ok: [127.0.0.1] => (item=libapache2-mod-php5)
changed: [127.0.0.1] => (item=php5-mysql)
changed: [127.0.0.1] => (item=php5-gd)
changed: [127.0.0.1] => (item=php5-geoip)
changed: [127.0.0.1] => (item=php5-ldap)
TASK: [ansible-piwik | Install general dependencies] **************************
changed: [127.0.0.1] => (item=unzip)
TASK: [ansible-piwik | Check if empty MySQL admin password] *******************
changed: [127.0.0.1]
TASK: [ansible-piwik | Change MySQL root password] ****************************
changed: [127.0.0.1]
TASK: [ansible-piwik | Manage Piwik db] ***************************************
changed: [127.0.0.1]
TASK: [ansible-piwik | Manage Piwik db-user] **********************************
changed: [127.0.0.1]
TASK: [ansible-piwik | Fetch latest Piwik release] ****************************
changed: [127.0.0.1]
TASK: [ansible-piwik | Create Piwik destination folder] ***********************
changed: [127.0.0.1]
TASK: [ansible-piwik | Extract Piwik zipfile] *********************************
changed: [127.0.0.1]
TASK: [ansible-piwik | Create Piwik temp folders] *****************************
changed: [127.0.0.1] => (item=tmp)
changed: [127.0.0.1] => (item=config)
TASK: [ansible-piwik | Add Piwik Apache Alias] ********************************
changed: [127.0.0.1]
TASK: [ansible-piwik | Fetch latest GeoIP database] ***************************
changed: [127.0.0.1]
TASK: [ansible-piwik | Extract GeoIP database] ********************************
changed: [127.0.0.1]
NOTIFIED: [ansible-piwik | Restart Apache] ************************************
changed: [127.0.0.1]
PLAY RECAP ********************************************************************
127.0.0.1 : ok=16 changed=15 unreachable=0 failed=0