Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ansible/group_vars/vagrant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,11 @@ kv_store: etcd
etcd_client_port: 2379
docker_port: 2375
swarm_port: 3375

influxdb:
host: 192.168.44.11
port: 8086

grafana:
host: 192.168.44.11
port: 3000
6 changes: 6 additions & 0 deletions ansible/inventory/vagrant
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ node-[1:3]

[vagrant:children]
nodes

[influxdb_server]
node-1

[grafana_server]
node-1
10 changes: 10 additions & 0 deletions ansible/roles/grafana/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
# defaults file for grafana
grafana:
version: 3.0.1-1
host: 192.168.44.11
port: 3000
admin: admin
admin_password: admin
conf_dir: /etc/grafana
root: /var/lib/grafana
5 changes: 5 additions & 0 deletions ansible/roles/grafana/files/grafana.repo
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[grafana]
name=grafana
baseurl=https://packagecloud.io/grafana/stable/el/6/$basearch
enabled=1
gpgcheck=0
4 changes: 4 additions & 0 deletions ansible/roles/grafana/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
# handlers file for grafana
- name: restart grafana
service: name=grafana-server state=restarted
32 changes: 32 additions & 0 deletions ansible/roles/grafana/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
galaxy_info:
author: Jishnu Vijayan
description: Monitoring solution for upswing
company: DigitalEarns (Infrastructure)
# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker
# Some suggested licenses:
# - BSD (default)
# - MIT
# - GPLv2
# - GPLv3
# - Apache
# - CC-BY
license: license (GPLv2, CC-BY, etc)
min_ansible_version: 1.2
#
# Below are all platforms currently available. Just uncomment
# the ones that apply to your role. If you don't see your
# platform on this list, let us know and we'll get it added!
#
#platforms:
#
# Below are all categories currently available. Just as with
# the platforms above, uncomment those that apply to your role.
#
#categories:
dependencies: []
# List your role dependencies here, one per line.
# Be sure to remove the '[]' above if you add dependencies
# to this list.
47 changes: 47 additions & 0 deletions ansible/roles/grafana/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
- include_vars: ../../telegraf/defaults/main.yml

- name: configure grafana repo
copy: src=grafana.repo dest=/etc/yum.repos.d/grafana.repo owner=root group=root

- name: install grafana
yum: name=grafana-{{ grafana.version }} state=present

- name: configure grafana
template: src=grafana.ini.j2 dest={{ grafana.conf_dir }}/grafana.ini
notify:
- restart grafana

- meta: flush_handlers

- name: start grafana-server
service: name=grafana-server enabled=yes state=started

- name: install python-httplib2.noarch
yum: name=python-httplib2.noarch state=present

- wait_for: port={{ grafana.port }} delay=10 timeout=20

- name: setup upswing datasource in grafana
uri:
url: http://{{ grafana.host }}:{{ grafana.port }}/api/datasources

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{{ grafana.host }} could be rewritten as using hostvars and groups
ref: http://serverfault.com/questions/638507/how-to-access-host-variable-of-a-different-host-with-ansible

method: POST
body: "{{ lookup('template','datasource.json') }}"
user: "{{ grafana.admin }}"
password: "{{ grafana.admin_password }}"
force_basic_auth: yes
body_format: json
HEADER_Content-Type: "application/json"
status_code: 200,500

- name: set up upswing dashboard
uri:
url: http://{{ grafana.host }}:{{ grafana.port }}/api/dashboards/db
method: POST
body: "{{ lookup('template','upswing_nodes.json') }}"
user: "{{ grafana.admin }}"
password: "{{ grafana.admin_password }}"
force_basic_auth: yes
body_format: json
HEADER_Content-Type: "application/json"
status_code: 200,412
14 changes: 14 additions & 0 deletions ansible/roles/grafana/templates/datasource.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

{
"name":"upswing_telegraf",
"type":"influxdb",
"access":"direct",
"isDefault":true,
"url":"http://{{ influxdb.host }}:{{ influxdb.port }}",
"user":"{{ telegraf.db.admin }}",
"password":"{{ telegraf.db.admin_password }}",
"database":"{{ telegraf.db.name }}",
"basicAuth":false,
"basicAuthUser":"",
"basicAuthPassword":""
}
Loading