Will Foster b29d74f4de Replace dummy 1.1.1.1 values for graphite_host, grafana_host
This adds a sanity check that will fail if the user has not filled out
the grafana_host and graphite_host values in group_vars/all.yml

It will cause the grafana playbook execution to fail with a debug warning
which is cleaner than having it execute all the way through only to fail later.

We would ship these entries defined but empty as a result.

Patchset #2: correct typo in commit title
Patchset #3: move to top of playbook so if it fails it will be right away.
Patchset #4: README.MD update: specify that these values need to be filled in

Change-Id: I333798398ee0a84d1af51b9344b7c4798aad2043
2016-06-03 13:43:54 +01:00

84 lines
2.4 KiB
YAML

---
#
# Install/run grafana-server for browbeat
#
# check that grafana_host and graphite_host is entered prior to playbook run
- name: Check Graphite/Grafana Host IP Address
fail:
msg="** Edit grafana_host and graphite_host in ../install/group_vars/all.yml before running **"
when: ((grafana_host is none) and (graphite_host is none))
- name: Import EPEL GPG Key
rpm_key: key=https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7
state=present
- name: Check for EPEL repo
yum: name=https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
state=present
- name: Install grafana rpms
yum: name={{ item }} state=present
become: true
with_items:
- https://grafanarel.s3.amazonaws.com/builds/grafana-2.6.0-1.x86_64.rpm
- name: Set grafana server port
ini_file:
dest=/etc/grafana/grafana.ini
section={{item.section}}
option={{item.option}}
value={{item.value}}
with_items:
- section: server
option: http_port
value: "{{grafana_port}}"
- section: auth.anonymous
option: enabled
value: true
become: true
# disable firewalld (might need to create specific firewall rules or leave it to admin to do via iptables)
- name: disable firewalld
service: name=firewalld state=stopped enabled=false
become: true
#
# setup the grafana-server service
#
- name: Setup grafana-server service
service: name=grafana-server state=started enabled=true
become: true
ignore_errors: true
- name: Wait for grafana to be ready
wait_for: host={{grafana_host}} port={{grafana_port}} delay=5 timeout=30
#
# Add graphite server as a default datasource
#
- name: Ensure {{role_path}}/files directory exists
file: path={{role_path}}/files state=directory
connection: local
- name: Create data_source.json
template:
src: data_source.json.j2
dest: "{{role_path}}/files/data_source.json"
connection: local
- name: Create Data Source on grafana server
command: "curl -X POST -H 'Content-Type: application/json' -d @{{role_path}}/files/data_source.json http://{{grafana_username}}:{{grafana_password}}@{{grafana_host}}:{{grafana_port}}/api/datasources"
connection: local
- name: Remove leftover json file
file: path={{role_path}}/files/data_source.json state=absent
connection: local
- name: Disable EPEL Repo
ini_file: dest=/etc/yum.repos.d/epel.repo
section=epel
option=enabled
value=0