Commit ad8d6a0b by Toby Lawrence

Add a playbook to install Grafana.

parent b797db62
......@@ -15,6 +15,8 @@
gather_facts: True
roles:
- graphite
- grafana
- role: nginx
nginx_sites:
- graphite
- grafana
---
dependencies:
- role: common
tags:
- always
- config-encoders
---
#
# edX Configuration
#
# github: https://github.com/edx/configuration
# wiki: https://openedx.atlassian.net/wiki/display/OpenOPS
# code style: https://openedx.atlassian.net/wiki/display/OpenOPS/Ansible+Code+Conventions
# license: https://github.com/edx/configuration/blob/master/LICENSE.TXT
#
#
# Tasks for role graphite
#
# Overview:
#
# This task is to install Grafana, which is a UI for creating visualizations on top of
# common metrics data sources such as Graphite, InfluxDB, CloudWatch, and more.
#
# Dependencies:
# - common
# - config-encoders
#
- name: ensure correct OS
fail:
msg: "this playbook can only be run on an Ubuntu host"
when: ansible_distribution != "Ubuntu"
- name: install PackageCloud GPG key
apt_key:
id: "418A7F2FB0E1E6E7EABF6FE8C2E73424D59097AB"
url: "https://packagecloud.io/gpg.key"
state: present
tags:
- install
- install:system-requirements
- name: install PackageCloud PPA
apt_repository:
# This is Debian Jessie repository, when we use Ubuntu Xenial, yes. It's the latest Debian repository they
# populate for their official packages. It does work, so, *shrug*.
repo: "deb https://packagecloud.io/grafana/stable/debian/ jessie main"
update_cache: yes
state: present
tags:
- install
- install:system-requirements
- name: install grafana
apt:
name: "{{ grafana_apt_pkg }}"
state: present
tags:
- install
- install:system-requirements
- name: configure grafana
template:
src: "conf/grafana.ini.j2"
dest: "/etc/grafana/grafana.ini"
tags:
- install
- install:app-configuration
- name: enable grafana
service:
name: grafana-server
enabled: yes
state: started
tags:
- install
- install:configuration
- name: stop grafana
service:
name: grafana-server
state: stopped
tags:
- manage:stop
- name: restart grafana
service:
name: grafana-server
state: restarted
tags:
- manage:start
- manage:restart
{%- if "grafana" in nginx_default_sites -%}
{%- set default_site = "default_server" -%}
{%- else -%}
{%- set default_site = "" -%}
{%- endif -%}
#
# {{ ansible_managed }}
#
upstream grafana_app_server {
server 127.0.0.1:3000 fail_timeout=0;
}
server {
server_name grafana.*;
listen {{ GRAFANA_NGINX_PORT }} {{ default_site }};
client_max_body_size 1M;
keepalive_timeout 5;
location / {
try_files $uri @proxy_to_app;
}
location @proxy_to_app {
{% if NGINX_SET_X_FORWARDED_HEADERS %}
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-For $remote_addr;
{% else %}
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
proxy_set_header X-Forwarded-Port $http_x_forwarded_port;
proxy_set_header X-Forwarded-For $http_x_forwarded_for;
{% endif %}
# newrelic-specific header records the time when nginx handles a request.
proxy_set_header X-Queue-Start "t=${msec}";
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://grafana_app_server;
}
}
......@@ -20,7 +20,6 @@ upstream graphite_app_server {
}
server {
server_name graphite.*;
listen {{ GRAPHITE_NGINX_PORT }} {{ default_site }};
client_max_body_size 1M;
......
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