first commit

This commit is contained in:
felix.niederwanger@suse.com 2021-03-25 13:39:17 +01:00
commit 927300877c
10 changed files with 193 additions and 0 deletions

23
README.md Normal file
View file

@ -0,0 +1,23 @@
# geekoops-grafana
Easy ansible role for setup of `grafana` with a custom backend. Currently only `influxdb` is supported
## Role Variables
## Example Playbook
- hosts: jellyfish
roles:
- { role: geekoops-grafana }
## License
MIT
## Author Information
phoenix
Have a lot of fun!

18
defaults/main.yml Normal file
View file

@ -0,0 +1,18 @@
---
# defaults file for geekoops-grafana
config_firewall: false
firewall_zone: public
open_grafana_port: false
grafana_port: 3000
influxdb: false
influxdb_port: 8086
influxdb_bind: ""
open_influxdb_port: false
influxdb_collectd: false
influxdb_collectd_database: "collectd"
influxdb_collectd_port: 25826
influxdb_collectd_bind: ""
open_collectd_port: false

14
handlers/main.yml Normal file
View file

@ -0,0 +1,14 @@
---
# handlers file for geekoops-grafana
- name: reload firewalld
shell: firewall-cmd --reload
- name: restart influxdb
service:
name: influxdb
state: restarted
- name: restart grafana
service:
name: grafana-server
state: restarted

23
meta/main.yml Normal file
View file

@ -0,0 +1,23 @@
---
galaxy_info:
author: Felix Niederwanger
description: Configurable grafana installation role
company: SUSE
issue_tracker_url: https://github.com/GeekOops/geekoops-grafana/issues
license: license MIT
min_ansible_version: 2.9
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
platforms:
- name: opensuse
versions:
- 15.2
galaxy_tags:
- grafana
dependencies: []

24
tasks/grafana.yml Normal file
View file

@ -0,0 +1,24 @@
---
- name: Install grafana
package:
name: "{{ packages_grafana }}"
state: present
tags: ['grafana']
- name: Ensure grafana is started
systemd:
name: grafana-server
state: started
enabled: true
tags: ['grafana']
- name: Ensure grafana firewall port is open
firewalld:
zone: "{{ firewall_zone }}"
port: "{{grafana_port}}/tcp"
permanent: yes
state: enabled
when: config_firewall and open_grafana_port
notify: reload firewalld
tags: ['grafana', 'firewalld']

46
tasks/influxdb.yml Normal file
View file

@ -0,0 +1,46 @@
---
- name: Install influxdb
package:
name: "{{ packages_influxdb }}"
state: present
tags: ['influxdb']
- name: Ensure influxdb is configured
template:
src: influxdb_config.toml.j2
dest: /etc/influxdb/config.toml
owner: root
group: influxdb
mode: 0640
tags: ['influxdb']
notify: restart influxdb
- name: Ensure influxdb is enabled
systemd:
name: influxdb
state: started
enabled: true
tags: ['influxdb']
- name: Ensure influxdb firewall port is open
firewalld:
zone: "{{ firewall_zone }}"
port: "{{influxdb_port}}/tcp"
permanent: yes
state: enabled
when: config_firewall and open_influxdb_port
notify: reload firewalld
tags: ['influxdb', 'firewalld']
- name: Ensure collectd firewall port is open
firewalld:
zone: "{{ firewall_zone }}"
port: "{{influxdb_collectd_port}}/udp"
permanent: yes
state: enabled
when: config_firewall and open_collectd_port
notify: reload firewalld
tags: ['influxdb', 'firewalld']

11
tasks/main.yml Normal file
View file

@ -0,0 +1,11 @@
---
# tasks file for geekoops-grafana
# Distribution specific vars are ALWAYS needed, so don't forget the tags here
- name: include distribution specific vars
include_vars: "{{ansible_distribution}}_{{ansible_distribution_version}}.yml"
tags: ['grafana']
- include: influxdb.yml
when: influxdb == true
- include: grafana.yml

View file

@ -0,0 +1,29 @@
### InfluxDB config file managed by the grafana-influxdb ansible role
[meta]
# Where the metadata/raft database is stored
dir = "/var/lib/influxdb/meta"
[data]
# The directory where the TSM storage engine stores TSM files.
dir = "/var/lib/influxdb/data"
# The directory where the TSM storage engine stores WAL files.
wal-dir = "/var/lib/influxdb/wal"
[http]
enabled = true
flux-enabled = false
bind-address = "{{influxdb_bind}}:{{influxdb_port}}"
[logging]
format = "auto"
level = "error"
{% if influxdb_collectd %}
[[collectd]]
enabled = true
bind-address = "{{influxdb_collectd_bind}}:{{influxdb_collectd_port}}"
database = "{{influxdb_collectd_database}}"
typesdb = "/usr/share/collectd/types.db"
{% endif %}

2
vars/main.yml Normal file
View file

@ -0,0 +1,2 @@
---
# vars file for geekoops-grafana

View file

@ -0,0 +1,3 @@
---
packages_grafana: ['grafana', 'grafana-piechart-panel', 'grafana-status-panel']
packages_influxdb: ['influxdb']