2019-04-12 17:14:25 +00:00
|
|
|
---
|
|
|
|
- name: copy config file
|
|
|
|
template:
|
|
|
|
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
|
|
|
|
systemd:
|
|
|
|
name: influxdb
|
|
|
|
state: started
|
|
|
|
enabled: yes
|
|
|
|
tags: influxdb
|
|
|
|
|
|
|
|
- name: wait http api is up
|
|
|
|
wait_for:
|
|
|
|
port: 8086
|
|
|
|
timeout: 10
|
|
|
|
tags: influxdb
|
|
|
|
|
|
|
|
- name: create users
|
|
|
|
influxdb_user:
|
|
|
|
user_name: '{{ item.name }}'
|
|
|
|
user_password: '{{ item.password }}'
|
|
|
|
admin: '{{ item.admin|default(false) }}'
|
|
|
|
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
|
|
|
|
influxdb_user:
|
|
|
|
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
|
|
|
|
|
|
|
|
- name: create databases
|
|
|
|
influxdb_database:
|
|
|
|
database_name: '{{ item }}'
|
|
|
|
username: '{{ influxdb_api_user }}'
|
|
|
|
password: '{{ influxdb_api_password }}'
|
|
|
|
loop: '{{ influxdb_databases }}'
|
|
|
|
tags: influxdb
|
|
|
|
|
|
|
|
- name: create privileges
|
|
|
|
influxdb_privilege:
|
|
|
|
user: '{{ item.user }}'
|
|
|
|
database: '{{ item.database }}'
|
|
|
|
privilege: '{{ item.privilege }}'
|
|
|
|
api_user: '{{ influxdb_api_user }}'
|
|
|
|
api_password: '{{ influxdb_api_password }}'
|
|
|
|
api_port: '{{ influxdb_api_port }}'
|
|
|
|
state: '{{ item.state|default("present") }}'
|
|
|
|
loop: '{{ influxdb_privileges }}'
|
|
|
|
tags: influxdb
|