Add influxdb role

This commit is contained in:
Timotej Lazar 2024-09-27 16:14:10 +02:00
parent 1f5d2f6238
commit d0f3d828df
5 changed files with 89 additions and 0 deletions

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;
}
}