Commit a1ab1d5b authored by jaywink's avatar jaywink
Browse files

Initial role version

parents
ansible-facette
===============
A [Facette](https://facette.io/) role for [Ansible](https://www.ansible.com/).
Installs Facette, using Apache2 to proxy. Installs a provider, [collectd](https://collectd.org).
After using this role, check out [a short guide](https://blog.facette.io/2014/07/31/facette-101/) on how to create your first graphs using the stats collected by *collectd*.
Requirements
------------
Ubuntu 14.04.
Role Variables
--------------
facette_hostname: stats.example.com
Dependencies
------------
-
Example Playbook
----------------
- hosts: servers
roles:
- { role: ansible-facette, facette_hostname: stats.example.com }
License
-------
MIT
Author Information
------------------
Jason Robinson - https://jasonrobinson.me - https://iliketoast.net/u/jaywink
---
facette_hostname: example.com
---
- name: restart apache
service: name=apache2 state=restarted
- name: restart facette
service: name=facette state=restarted
---
galaxy_info:
author: Jason Robinson
description: Facette role for Ubuntu.
license: MIT
min_ansible_version: 1.9
platforms:
- name: Ubuntu
versions:
- trusty
categories:
- monitoring
- system
dependencies: []
---
## Apache
- name: Install Apache2
apt: name={{ item }} state=present update_cache=yes cache_valid_time=86400
with_items:
- apache2
- name: Ensure system locale in Apache envvars
lineinfile: dest=/etc/apache2/envvars line=". /etc/default/locale" insertbefore="export LANG" backup=yes
notify:
- restart apache
- name: Apache modules
apache2_module: state=present name={{ item }}
with_items:
- proxy
- ssl
- proxy_http
- headers
notify:
- restart apache
- name: Apache site
template: dest=/etc/apache2/sites-available/{{ facette_hostname }}.conf src=apache.conf.j2
- name: Enable site
command: a2ensite {{ facette_hostname }}
notify:
- restart apache
## Providers - collectd
- name: Install collectd
apt: name=collectd state=present update_cache=yes cache_valid_time=86400
notify:
- restart facette
## Facette
- name: Check if facette is installed
command: /usr/bin/dpkg -l facette
register: facette_installed
ignore_errors: True
- name: Download facette deb
command: /usr/bin/wget https://github.com/facette/facette/releases/download/0.3.0/facette_0.3.0-1.trusty_amd64.deb -O /tmp/facette_0.3.0-1.trusty_amd64.deb
when: facette_installed.rc == 1
- name: Install facette deb
apt: deb=/tmp/facette_0.3.0-1.trusty_amd64.deb
when: facette_installed.rc == 1
notify:
- restart facette
- name: Remove facette deb
file: path=/tmp/facette_0.3.0-1.trusty_amd64.deb state=absent
when: facette_installed.rc == 1
- name: Enable collectd provider
template: dest=/etc/facette/providers/collectd.json src=collectd_provider.j2
notify:
- restart facette
- name: Enable facette
lineinfile: line="ENABLED=true" dest=/etc/default/facette state=present
notify:
- restart facette
<VirtualHost *:80>
ServerName {{ facette_hostname }}
RequestHeader set X-Forwarded-Proto "http"
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://localhost:12003/
ProxyPassReverse / http://localhost:12003/
</VirtualHost>
{
"connector": {
"type": "rrd",
"path": "/var/lib/collectd/rrd",
"pattern": "(?P<source>[^/]+)/(?P<metric>.+).rrd"
},
"filters": [
{ "action": "sieve", "target": "metric", "pattern": "/average$" },
{ "action": "rewrite", "target": "metric", "pattern": "/average$", "into": "" },
{ "action": "rewrite", "target": "metric", "pattern": "/", "into": "." },
{ "action": "rewrite", "target": "metric", "pattern": "^cpu-(\\d+)\\.cpu-(.+)\\.value$", "into": "cpu.$1.$2" },
{ "action": "rewrite", "target": "metric", "pattern": "^df-(.+)\\.df_complex-(.+)\\.value", "into": "df.$1.$2" },
{ "action": "rewrite", "target": "metric", "pattern": "^disk-(.+)\\.disk_(.+)", "into": "disk.$1.$2" },
{ "action": "rewrite", "target": "metric", "pattern": "^entropy\\.entropy", "into": "entropy" },
{ "action": "rewrite", "target": "metric", "pattern": "^interface-(.+)\\.if_(.+)\\.(.+)$", "into": "net.$1.$2.$3" },
{ "action": "rewrite", "target": "metric", "pattern": "^irq.irq-(.+)\\.value$", "into": "irq.$1" },
{ "action": "rewrite", "target": "metric", "pattern": "^load\\.load", "into": "load" },
{ "action": "rewrite", "target": "metric", "pattern": "^memory\\.memory-(.+)\\.value$", "into": "memory.$1" },
{ "action": "rewrite", "target": "metric", "pattern": "^processes\\.ps_state-(.+)\\.value$", "into": "proc.state.$1" },
{ "action": "rewrite", "target": "metric", "pattern": "^processes\\.(.+)\\.value$", "into": "proc.$1" },
{ "action": "rewrite", "target": "metric", "pattern": "^swap\\.swap-(.+)\\.value$", "into": "swap.$1" },
{ "action": "rewrite", "target": "metric", "pattern": "^swap\\.swap_io-(.+)\\.value$", "into": "swap.io.$1" },
{ "action": "rewrite", "target": "metric", "pattern": "^users\\.users\\.value", "into": "users.count" }
],
"refresh_interval": 300
}
---
# vars file for ansible-facette
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment