Giter Site home page Giter Site logo

ansible-piwik's Introduction

Readme

Description

ansible-piwik is an Ansible role. The playbook contains tasks to provide a Piwik installation (with MySQL backend) running on Apache.

Provides

  1. MySQL
  2. Apache
  3. PHP
  4. Latest Piwik codebase
  5. GeoIP database

Requires

  1. Ansible 1.4 or higher
  2. Debian 7.3 (other deb-based distros should work too)
  3. Vagrant (optional)

Note: Tested on Fedora 20 but requires some custom host_vars see below:

---
piwik:
  mysql:
    service: 'mysqld'
  apache:
    user: 'apache'
    group: 'apache'
    service: 'httpd'

(If necessary adjust firewall rules to allow http...)

Usage

Get the code

$ git clone [email protected]:ICTO/ansible-piwik.git

Custom settings

Create an Ansible inventory file

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

Create the playbook file

---
- name: Piwik
  hosts: piwik
  roles:
    - ansible-piwik

Create host or group specific variables

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

  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

Run the playbook

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

Example output

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   

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.