ansible-role-influxdb/tasks/config.yml

70 lines
1.9 KiB
YAML
Raw Normal View History

2019-04-12 17:14:25 +00:00
---
- name: copy config file
2021-08-18 12:57:25 +00:00
ansible.builtin.template:
2019-04-12 17:14:25 +00:00
src: influxdb.conf.j2
dest: /etc/influxdb/influxdb.conf
owner: root
group: root
mode: 0644
notify: restart influxdb
tags: influxdb
- name: start and enable service
2021-08-18 12:57:25 +00:00
ansible.builtin.service:
2019-04-12 17:14:25 +00:00
name: influxdb
state: started
enabled: yes
tags: influxdb
- name: wait http api is up
2021-08-18 12:57:25 +00:00
ansible.builtin.wait_for:
2019-04-12 17:14:25 +00:00
port: 8086
timeout: 10
tags: influxdb
2021-08-18 13:30:41 +00:00
- name: create databases
community.general.influxdb_database:
database_name: '{{ item }}'
username: '{{ influxdb_api_user }}'
password: '{{ influxdb_api_password }}'
loop: '{{ influxdb_databases }}'
tags: influxdb
2021-08-18 14:48:14 +00:00
- name: create retention policies
community.general.influxdb_retention_policy:
policy_name: '{{ item.name }}'
database_name: '{{ item.database }}'
duration: '{{ item.duration }}'
replication: '{{ item.replication|default(1) }}'
default: '{{ item.default|default(False) }}'
username: '{{ influxdb_api_user }}'
password: '{{ influxdb_api_password }}'
loop: '{{ influxdb_retention_policies }}'
tags: influxdb
2019-04-12 17:14:25 +00:00
- name: create users
2021-08-18 12:57:25 +00:00
community.general.influxdb_user:
2019-04-12 17:14:25 +00:00
user_name: '{{ item.name }}'
user_password: '{{ item.password }}'
admin: '{{ item.admin|default(false) }}'
2021-08-18 13:30:41 +00:00
grants: '{{ item.grants|default([]) }}'
2019-04-12 17:14:25 +00:00
username: '{{ influxdb_api_user }}'
password: '{{ influxdb_api_password }}'
loop: '{{ influxdb_users }}'
2021-08-18 12:40:19 +00:00
loop_control:
label: '{{ item.name }}'
2019-04-12 17:14:25 +00:00
when: item.state is not defined or item.state != 'absent'
tags: influxdb
- name: delete users
2021-08-18 12:57:25 +00:00
community.general.influxdb_user:
2019-04-12 17:14:25 +00:00
user_name: '{{ item.name }}'
username: '{{ influxdb_api_user }}'
password: '{{ influxdb_api_password }}'
state: absent
loop: '{{ influxdb_users }}'
2021-08-18 12:40:19 +00:00
loop_control:
label: '{{ item.name }}'
2019-04-12 17:14:25 +00:00
when: item.state is defined and item.state == 'absent'
tags: influxdb