docs: rewrite README with structured overview and quick start guide
Replaces the minimal project description with a comprehensive README including a component overview table, quick start instructions, common Ansible operations, and links to detailed documentation. Aligns with Red Panda Approval™ standards.
This commit is contained in:
113
ansible/grafana/deploy.yml
Normal file
113
ansible/grafana/deploy.yml
Normal file
@@ -0,0 +1,113 @@
|
||||
---
|
||||
- name: Deploy Grafana
|
||||
hosts: ubuntu
|
||||
become: true
|
||||
tasks:
|
||||
- name: Check if host has grafana service
|
||||
ansible.builtin.set_fact:
|
||||
has_grafana_service: "{{'grafana' in services}}"
|
||||
|
||||
- name: Skip hosts without grafana service
|
||||
ansible.builtin.meta: end_host
|
||||
when: not has_grafana_service
|
||||
|
||||
- name: Add Grafana repository
|
||||
ansible.builtin.deb822_repository:
|
||||
name: grafana
|
||||
types: [deb]
|
||||
uris: https://apt.grafana.com
|
||||
suites: [stable]
|
||||
components: [main]
|
||||
signed_by: https://apt.grafana.com/gpg.key
|
||||
state: present
|
||||
|
||||
- name: Install Grafana
|
||||
become: true
|
||||
ansible.builtin.apt:
|
||||
name: grafana
|
||||
state: present
|
||||
update_cache: true
|
||||
|
||||
- name: Create provisioning directories
|
||||
become: true
|
||||
ansible.builtin.file:
|
||||
path: "{{item}}"
|
||||
state: directory
|
||||
owner: grafana
|
||||
group: grafana
|
||||
mode: '750'
|
||||
loop:
|
||||
- /etc/grafana/provisioning/dashboards
|
||||
- /etc/grafana/provisioning/datasources
|
||||
- /etc/grafana/provisioning/users
|
||||
|
||||
- name: Create dashboards directory
|
||||
become: true
|
||||
ansible.builtin.file:
|
||||
path: /var/lib/grafana/dashboards
|
||||
state: directory
|
||||
owner: grafana
|
||||
group: grafana
|
||||
mode: '750'
|
||||
|
||||
- name: Template configuration files
|
||||
become: true
|
||||
ansible.builtin.template:
|
||||
src: "{{item.src}}"
|
||||
dest: "{{item.dest}}"
|
||||
owner: grafana
|
||||
group: grafana
|
||||
mode: '550'
|
||||
loop:
|
||||
- src: "datasource.yml.j2"
|
||||
dest: "/etc/grafana/provisioning/datasources/prometheus.yml"
|
||||
- src: "users.yml.j2"
|
||||
dest: "/etc/grafana/provisioning/users/users.yml"
|
||||
notify: restart grafana
|
||||
|
||||
- name: Template Grafana main configuration
|
||||
become: true
|
||||
ansible.builtin.template:
|
||||
src: "grafana.ini.j2"
|
||||
dest: "/etc/grafana/grafana.ini"
|
||||
owner: grafana
|
||||
group: grafana
|
||||
mode: '640'
|
||||
when: grafana_oauth_enabled | default(false)
|
||||
notify: restart grafana
|
||||
|
||||
- name: Configure dashboard provisioning
|
||||
become: true
|
||||
ansible.builtin.copy:
|
||||
content: |
|
||||
apiVersion: 1
|
||||
providers:
|
||||
- name: 'default'
|
||||
orgId: 1
|
||||
folder: ''
|
||||
type: file
|
||||
disableDeletion: false
|
||||
updateIntervalSeconds: 10
|
||||
allowUiUpdates: true
|
||||
options:
|
||||
path: /var/lib/grafana/dashboards
|
||||
dest: /etc/grafana/provisioning/dashboards/dashboard.yml
|
||||
owner: grafana
|
||||
group: grafana
|
||||
mode: '550'
|
||||
notify: restart grafana
|
||||
|
||||
- name: Enable and start Grafana service
|
||||
become: true
|
||||
ansible.builtin.systemd:
|
||||
name: grafana-server
|
||||
enabled: true
|
||||
state: started
|
||||
daemon_reload: true
|
||||
|
||||
handlers:
|
||||
- name: restart grafana
|
||||
become: true
|
||||
ansible.builtin.systemd:
|
||||
name: grafana-server
|
||||
state: restarted
|
||||
Reference in New Issue
Block a user