98 lines
2.6 KiB
YAML
98 lines
2.6 KiB
YAML
---
|
|
- name: gather os specific variables
|
|
ansible.builtin.include_vars: "{{ lookup('first_found', params) }}"
|
|
vars:
|
|
params:
|
|
files:
|
|
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yaml"
|
|
- "{{ ansible_distribution }}.yaml"
|
|
- "{{ ansible_os_family }}.yaml"
|
|
- "default.yaml"
|
|
paths:
|
|
- vars
|
|
|
|
- name: include os specific tasks
|
|
ansible.builtin.include_tasks: "{{ lookup('first_found', params) }}"
|
|
vars:
|
|
params:
|
|
files:
|
|
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yaml"
|
|
- "{{ ansible_distribution }}.yaml"
|
|
- "default.yaml"
|
|
paths:
|
|
- tasks
|
|
|
|
- name: include os family specific tasks
|
|
ansible.builtin.include_tasks: "{{ lookup('first_found', params) }}"
|
|
vars:
|
|
params:
|
|
files:
|
|
- "{{ ansible_os_family }}.yaml"
|
|
- "default.yaml"
|
|
paths:
|
|
- tasks
|
|
|
|
- name: install package
|
|
ansible.builtin.package:
|
|
name: "{{ grafana_package_name }}"
|
|
state: "{{ grafana_package_state }}"
|
|
|
|
- name: "create {{ grafana_etc_path }}"
|
|
ansible.builtin.file:
|
|
path: "{{ grafana_etc_path }}"
|
|
owner: root
|
|
group: root
|
|
mode: 0755
|
|
|
|
- name: configure
|
|
ansible.builtin.template:
|
|
src: grafana.ini.j2
|
|
dest: "{{ grafana_config_path }}"
|
|
owner: root
|
|
group: "{{ grafana_group }}"
|
|
mode: 0640
|
|
notify: restart grafana
|
|
|
|
- name: provision datasources
|
|
ansible.builtin.copy:
|
|
dest: "{{ grafana_provisioning_path }}/datasources/datasource.yaml"
|
|
content: "{{ grafana_datasources | to_nice_yaml }}"
|
|
owner: root
|
|
group: "{{ grafana_group }}"
|
|
mode: 0640
|
|
|
|
- name: create dashboard directory
|
|
ansible.builtin.file:
|
|
path: /var/lib/grafana/dashboards
|
|
state: directory
|
|
owner: "{{ grafana_user }}"
|
|
group: "{{ grafana_group }}"
|
|
mode: 0755
|
|
|
|
- name: provision dashboards
|
|
ansible.builtin.copy:
|
|
dest: "{{ grafana_provisioning_path }}/dashboards/dashboards.yaml"
|
|
content: "{{ grafana_dashboards | to_nice_yaml }}"
|
|
owner: root
|
|
group: "{{ grafana_group }}"
|
|
mode: 0640
|
|
|
|
- name: upload user dashboards
|
|
ansible.builtin.copy:
|
|
src: "files/grafana/dashboards/{{ item }}"
|
|
dest: "/var/lib/grafana/dashboards/{{ item | basename }}"
|
|
owner: "{{ grafana_user }}"
|
|
group: "{{ grafana_group }}"
|
|
mode: 0644
|
|
loop: "{{ grafana_dashboard_files | default([]) }}"
|
|
|
|
- name: manage service
|
|
ansible.builtin.service:
|
|
name: "{{ grafana_service_name }}"
|
|
state: "{{ grafana_service_state }}"
|
|
enabled: "{{ grafana_service_enabled }}"
|
|
|
|
- name: configure nginx
|
|
ansible.builtin.include_tasks: nginx.yaml
|
|
when: "'nginx' in ansible_play_role_names"
|