From 642df4fb6653bd67f398a08412e77fda9b2dfe03 Mon Sep 17 00:00:00 2001 From: binary Date: Fri, 22 Jan 2021 11:46:52 +0100 Subject: Add grafana to OpenBSD cloud server --- roles/grafana/meta/main.yml | 6 ++++++ roles/grafana/tasks/main.yml | 26 +++++-------------------- roles/grafana/templates/grafana.conf.nginx.j2 | 9 +++++++++ roles/grafana/templates/grafana.ini.j2 | 6 +++--- roles/grafana/templates/grafana_reverse.conf.j2 | 9 --------- 5 files changed, 23 insertions(+), 33 deletions(-) create mode 100644 roles/grafana/meta/main.yml create mode 100644 roles/grafana/templates/grafana.conf.nginx.j2 delete mode 100644 roles/grafana/templates/grafana_reverse.conf.j2 (limited to 'roles') diff --git a/roles/grafana/meta/main.yml b/roles/grafana/meta/main.yml new file mode 100644 index 0000000..21c98ab --- /dev/null +++ b/roles/grafana/meta/main.yml @@ -0,0 +1,6 @@ + +# grafana ~~ roles/grafana/meta/main.yml +# Meta parameters + +--- + diff --git a/roles/grafana/tasks/main.yml b/roles/grafana/tasks/main.yml index 39786af..5df8fa3 100644 --- a/roles/grafana/tasks/main.yml +++ b/roles/grafana/tasks/main.yml @@ -7,38 +7,22 @@ - name: install grafana package: name=grafana state=present -- name: install nginx - package: name=nginx state=present - -- name: ensure grafana group exists - group: name=grafana state=present - -- name: ensure grafana user exists - user: - name: grafana - group: grafana - state: present - -# grafana is supposed to create grafana service! - - name: generate grafana configuration template: src: grafana.ini.j2 dest: /etc/grafana.ini owner: "{{ user_root }}" - group: "{{ grafana_group }}" - mode: 0640 + group: "{{ group_root }}" + mode: 0644 - name: generate reverse proxy configuration for nginx template: - src: grafana_reverse.conf.j2 - dest: /etc/nginx/conf.d/grafana_reverse.conf + src: grafana.conf.nginx.j2 + dest: /etc/nginx/conf.d/grafana.conf owner: "{{ user_root }}" group: "{{ group_root }}" mode: 0644 + when: ansible_distribution != "OpenBSD" - name: start and enable grafana service service: name=grafana state=restarted enabled=true - -- name: start and enable nginx for reverse proxy - service: name=nginx state=restarted enabled=true diff --git a/roles/grafana/templates/grafana.conf.nginx.j2 b/roles/grafana/templates/grafana.conf.nginx.j2 new file mode 100644 index 0000000..c0f926c --- /dev/null +++ b/roles/grafana/templates/grafana.conf.nginx.j2 @@ -0,0 +1,9 @@ +server { + listen {{ grafana_port_out }}; + root /usr/share/nginx/html; + index index.html index.htm; + + location / { + proxy_pass http://127.0.0.1:{{ grafana_port }}/; + } +} diff --git a/roles/grafana/templates/grafana.ini.j2 b/roles/grafana/templates/grafana.ini.j2 index 16453b8..75de264 100644 --- a/roles/grafana/templates/grafana.ini.j2 +++ b/roles/grafana/templates/grafana.ini.j2 @@ -15,7 +15,7 @@ instance_name = #################################### Paths #################################### [paths] # Path to where grafana can store temp files, sessions, and the sqlite3 db (if that is used) -;data = /var/lib/grafana +data = {{ grafana_dir }} # Temporary files in `data` directory older than given duration will be removed ;temp_data_lifetime = 24h @@ -24,7 +24,7 @@ instance_name = ;logs = /var/log/grafana # Directory where grafana will automatically scan and look for plugins -;plugins = /var/lib/grafana/plugins +;plugins = {{ grafana_dir }}/plugins # folder that contains provisioning config files that grafana will apply on startup and while running. ;provisioning = conf/provisioning @@ -35,7 +35,7 @@ instance_name = ;protocol = http # The ip address to bind to, empty will bind to all interfaces -;http_addr = 192.168.5.1 +http_addr = # The http port to use http_port = {{ grafana_port }} diff --git a/roles/grafana/templates/grafana_reverse.conf.j2 b/roles/grafana/templates/grafana_reverse.conf.j2 deleted file mode 100644 index c0f926c..0000000 --- a/roles/grafana/templates/grafana_reverse.conf.j2 +++ /dev/null @@ -1,9 +0,0 @@ -server { - listen {{ grafana_port_out }}; - root /usr/share/nginx/html; - index index.html index.htm; - - location / { - proxy_pass http://127.0.0.1:{{ grafana_port }}/; - } -} -- cgit v1.2.3