infra/roles/monitoring-server/tasks/influxdb.yml

137 lines
3.0 KiB
YAML

---
- name: template influxdb config
template:
src: influxdb.conf.j2
dest: /etc/influxdb/influxdb.conf
notify:
- restart influxdb
tags:
- influxdb-config
- name: ensure ownership
file:
path: /var/lib/influxdb
owner: influxdb
group: influxdb
recurse: true
- name: install pip3 packages for influxdb (and scripts)
pip:
name:
- influxdb
- lxml
state: present
executable: pip3
tags:
- pip
- packages
- influxdb-scripts
- name: nginx vhost
template:
src: 01-influxdb.j2
dest: /etc/nginx/sites-enabled/01-influxdb
notify: reload nginx
tags:
- nginx-config
- nginx-influxdb
- nginx
# fails after the first time, since after that
- name: create influxdb admin user
influxdb_user:
user_name: "{{ influxdb_admin_user }}"
user_password: "{{ influxdb_admin_password }}"
login_username: "{{ influxdb_admin_user }}"
login_password: "{{ influxdb_admin_password }}"
admin: true
notify:
- restart influxdb
tags:
- influxdb-config
- name: create influxdb databases
influxdb_database:
database_name: "{{ item.key }}"
login_username: "{{ influxdb_admin_user }}"
login_password: "{{ influxdb_admin_password }}"
with_items: "{{ influxdb_user_database | dict2items}}"
loop_control:
label: "{{ item.key }}"
tags:
- influxdb-config
- name: create influxdb users
influxdb_user:
user_name: "{{ item.key }}"
user_password: "{{ item.value }}"
grants:
- database: "{{ item.key }}"
privilege: ALL
login_username: "{{ influxdb_admin_user }}"
login_password: "{{ influxdb_admin_password }}"
admin: false
with_items: "{{ influxdb_user_database | dict2items }}"
loop_control:
label: "{{ item.key }}"
tags:
- influxdb-config
- name: create infinite retention policies
influxdb_retention_policy:
database_name: "{{ item.key }}"
policy_name: "{{ item.key }}-infinite"
duration: INF
default: true
replication: 1
login_username: "{{ influxdb_admin_user }}"
login_password: "{{ influxdb_admin_password }}"
with_items: "{{ influxdb_user_database | dict2items}}"
loop_control:
label: "{{ item.key }}"
changed_when: false
tags:
- influxdb-config
- name: template scripts
template:
src: "{{ item }}.j2"
dest: /usr/local/bin/{{ item }}
mode: 0775
tags:
- influxdb-scripts
- influxdb-backup
with_items:
- hospital.py
- berlinrona.py
- sdfcheck.py
- impfstoff.py
- influxdb_backup.sh
- matrix-federation.py
- name: template cronjobs fr data collection scripts
template:
src: influxdb_collectors_cron.j2
dest: /etc/cron.d/influxdb_collectors
tags:
- influxdb-scripts
- name: backup dir
file:
state: directory
path: "{{ influxdb_backup_path }}"
owner: root
group: root
mode: 0700
tags: influxdb-backup
- name: backup cron
template:
src: influxdb_backup-cron.j2
dest: /etc/cron.d/influxdb_backup
owner: root
group: root
mode: 0600
tags: influxdb-backup