Compare commits

...

2 commits

Author SHA1 Message Date
Timotej Lazar b818249d82 Add grafana role 2024-09-27 16:14:23 +02:00
Timotej Lazar d0f3d828df Add influxdb role 2024-09-27 16:14:10 +02:00
8 changed files with 141 additions and 0 deletions

View file

@ -0,0 +1,11 @@
- name: restart grafana
service:
name: grafana
state: restarted
when: "'handler' not in ansible_skip_tags"
- name: reload nginx
service:
name: nginx
state: reloaded
when: "'handler' not in ansible_skip_tags"

View file

@ -0,0 +1,28 @@
- name: Install packages
package:
name: grafana
- name: Configure grafana
ini_file:
path: /etc/grafana.ini
section: '{{ item.section | default("") }}'
option: '{{ item.option }}'
value: '{{ item.value }}'
loop:
- { section: analytics, option: reporting_enabled, value: false }
- { section: analytics, option: check_for_updates, value: false }
- { section: analytics, option: check_for_plugin_updates, value: false }
- { section: news, option: news_feed_enabled, value: false }
- { section: public_dashboards, option: enabled, value: false }
- name: Set up nginx site
template:
dest: '/etc/nginx/http.d/grafana.conf'
src: 'nginx.conf.j2'
notify: reload nginx
- name: Enable grafana
service:
name: grafana
enabled: yes
state: started

View file

@ -0,0 +1,13 @@
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name {{ dns_name }};
ssl_certificate /etc/letsencrypt/live/{{ dns_name }}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/{{ dns_name }}/privkey.pem;
location / {
proxy_pass http://localhost:3000;
proxy_set_header Host $host;
}
}

View file

@ -0,0 +1,2 @@
reporting-disabled = true
http-bind-address = "localhost:8087"

View file

@ -0,0 +1,16 @@
#!/sbin/openrc-run
command="influxd"
command_background="yes"
command_user="${command_user:-influxdb:influxdb}"
directory="${data_path:-/var/lib/influxdb}"
pidfile="/run/$RC_SVCNAME.pid"
start_stop_daemon_args="--stdout-logger /usr/bin/logger"
depend() {
use logger
}
start_pre() {
checkpath -d -o "$command_user" -m755 "${data_path:-/var/lib/influxdb}"
}

View file

@ -0,0 +1,11 @@
- name: restart influxdb
service:
name: influxdb
state: restarted
when: "'handler' not in ansible_skip_tags"
- name: reload nginx
service:
name: nginx
state: reloaded
when: "'handler' not in ansible_skip_tags"

View file

@ -0,0 +1,48 @@
- name: Create influxdb group
group:
name: influxdb
system: yes
- name: Create influxdb user
user:
name: influxdb
system: yes
home: /var/lib/influxdb
shell: /sbin/nologin
- name: Install tar
package:
name: tar
- name: Install influxdb
unarchive:
src: https://download.influxdata.com/influxdb/releases/influxdb2-{{ influxdb_version }}_linux_amd64.tar.gz
dest: /
remote_src: yes
extra_opts:
- '--strip-components=1'
notify: restart influxdb
- name: Install influxdb initscript
copy:
dest: /etc/init.d/influxdb
src: influxdb.initd
mode: 0755
notify: restart influxdb
- name: Configure influxdb
copy:
dest: /var/lib/influxdb/
src: config.toml
- name: Set up nginx site
template:
dest: '/etc/nginx/http.d/influxdb.conf'
src: 'nginx.conf.j2'
notify: reload nginx
- name: Enable influxdb
service:
name: influxdb
enabled: yes
state: started

View file

@ -0,0 +1,12 @@
server {
listen 8086 ssl;
listen [::]:8086 ssl;
server_name {{ dns_name }};
ssl_certificate /etc/letsencrypt/live/{{ dns_name }}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/{{ dns_name }}/privkey.pem;
location / {
proxy_pass http://localhost:8087;
}
}