-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgrafana_install.yml
53 lines (52 loc) · 3.5 KB
/
grafana_install.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
---
- hosts: all
tasks:
- name: Ensiring that podman is in the system
block:
- name: Add Grafana Repo
yum_repository:
name: grafana
baseurl: https://packages.grafana.com/oss/rpm
gpgcheck: yes
enabled: yes
gpgkey: https://packages.grafana.com/gpg.key
description: grafana
- name: Installing grafana server
package:
name: grafana
state: present
- name:
service:
name: grafana-server # required. Name of the service.
enabled: True # not required. Whether the service should start on boot. B(At least one of state and enabled are required.)
state: restarted # not required. choices: reloaded;restarted;started;stopped. C(started)/C(stopped) are idempotent actions that will not run commands unless necessary. C(restarted) will always bounce the service. C(reloaded) will always reload. B(At least one of state and enabled are required.) Note that reloaded will start the service if it is not already started, even if your chosen init system wouldn't normally.
- name:
firewalld:
state: enabled # required. choices: enabled;disabled;present;absent. Enable or disable a setting. For ports: Should this port accept(enabled) or reject(disabled) connections. The states "present" and "absent" can only be used in zone level operations (i.e. when no other parameters but zone and state are set).
permanent: yes # not required. Should this configuration be in the running firewalld configuration or persist across reboots. As of Ansible version 2.3, permanent operations can operate on firewalld configs when it's not running (requires firewalld >= 3.0.9). (NOTE: If this is false, immediate is assumed true.)d
port: '{{ item }}/tcp' # not required. Name of a port or port range to add/remove to/from firewalld. Must be in the form PORT/PROTOCOL or PORT-PORT/PROTOCOL for port ranges.
loop:
- 3000
- name: Restarting firewallD serice
service:
name: firewalld # required. Name of the service.
state: restarted # not required. choices: reloaded;restarted;started;stopped. C(started)/C(stopped) are idempotent actions that will not run commands unless necessary. C(restarted) will always bounce the service. C(reloaded) will always reload. B(At least one of state and enabled are required.) Note that reloaded will start the service if it is not already started, even if your chosen init system wouldn't normally.
#### Setting up grafana server
- name: Setting up Grafana Password
command: 'grafana-cli admin reset-admin-password {{ grafana_password }}'
- name: Adding Influxdb Datasource
grafana_datasource:
grafana_url: http://localhost:3000 # required. The Grafana URL.
ds_type: influxdb # required. choices: graphite;prometheus;elasticsearch;influxdb;opentsdb;mysql;postgres;alexanderzobnin-zabbix-datasource. The type of the datasource.
name: InfluxDBAnsible-Demo # required. The name of the datasource.
database: '{{ influxdb_database_name }}'
url: http://localhost:8086 # required. The URL of the datasource.
grafana_user: admin
grafana_password: '{{ grafana_password }}'
- name: Copy json file with pre-defined dashboard
template:
src: ansible_demo_dashboard.j2
dest: /tmp/ansible_demo_dashboard.json
mode: 0777
when:
- "'mgmt' in group_names"