Add grafana role
This commit is contained in:
12
roles/grafana/tasks/Debian.yaml
Normal file
12
roles/grafana/tasks/Debian.yaml
Normal file
@ -0,0 +1,12 @@
|
||||
---
|
||||
- name: add grafana apt key
|
||||
apt_key:
|
||||
url: https://packages.grafana.com/gpg.key
|
||||
state: present
|
||||
|
||||
- name: configure apt repository
|
||||
apt_repository:
|
||||
repo: "deb https://packages.grafana.com/oss/deb stable main"
|
||||
filename: influxdb
|
||||
update_cache: yes
|
||||
state: present
|
55
roles/grafana/tasks/main.yaml
Normal file
55
roles/grafana/tasks/main.yaml
Normal file
@ -0,0 +1,55 @@
|
||||
---
|
||||
- name: gather os specific variables
|
||||
include_vars: "{{ lookup('first_found', possible_files) }}"
|
||||
vars:
|
||||
possible_files:
|
||||
files:
|
||||
- "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yaml"
|
||||
- "{{ ansible_distribution }}.yaml"
|
||||
- "{{ ansible_os_family }}.yaml"
|
||||
- "default.yaml"
|
||||
paths:
|
||||
- vars
|
||||
|
||||
- name: include os specific tasks
|
||||
include_tasks: "{{ lookup('first_found', possible_files) }}"
|
||||
vars:
|
||||
possible_files:
|
||||
files:
|
||||
- "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yaml"
|
||||
- "{{ ansible_distribution }}.yaml"
|
||||
- "{{ ansible_os_family }}.yaml"
|
||||
- "default.yaml"
|
||||
paths:
|
||||
- tasks
|
||||
|
||||
- name: install package
|
||||
package:
|
||||
name: "{{ grafana_package_name }}"
|
||||
state: "{{ grafana_package_state }}"
|
||||
|
||||
- name: "create {{ grafana_etc_path }}"
|
||||
file:
|
||||
path: "{{ grafana_etc_path }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
|
||||
- name: configure
|
||||
template:
|
||||
src: grafana.ini.j2
|
||||
dest: "{{ grafana_config_path }}"
|
||||
owner: root
|
||||
group: "{{ grafana_group }}"
|
||||
mode: 0640
|
||||
notify: restart grafana
|
||||
|
||||
- name: manage service
|
||||
service:
|
||||
name: "{{ grafana_service_name }}"
|
||||
state: "{{ grafana_service_state }}"
|
||||
enabled: "{{ grafana_service_enabled }}"
|
||||
|
||||
- name: configure nginx
|
||||
include: nginx.yaml
|
||||
when: "'nginx' in ansible_play_role_names"
|
17
roles/grafana/tasks/nginx.yaml
Normal file
17
roles/grafana/tasks/nginx.yaml
Normal file
@ -0,0 +1,17 @@
|
||||
- name: configure nginx
|
||||
template:
|
||||
src: nginx.conf.j2
|
||||
dest: /etc/nginx/sites-available/grafana
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
notify: reload nginx
|
||||
|
||||
- name: activate site
|
||||
file:
|
||||
src: /etc/nginx/sites-available/grafana
|
||||
dest: /etc/nginx/sites-enabled/grafana
|
||||
owner: root
|
||||
group: root
|
||||
state: link
|
||||
notify: reload nginx
|
Reference in New Issue
Block a user