feat: add retention policies
This commit is contained in:
parent
0bacd505f0
commit
b19cfba1fa
6 changed files with 35 additions and 2 deletions
|
@ -11,6 +11,7 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/)
|
|||
|
||||
### Added
|
||||
|
||||
- add retention policies
|
||||
- add support for debian 11
|
||||
- add support for debian 10 and python3
|
||||
|
||||
|
|
|
@ -27,6 +27,15 @@ Install and configure InfluxDB
|
|||
state: present
|
||||
```
|
||||
|
||||
- `influxdb_retention_policies` - array with the retention policies
|
||||
|
||||
```
|
||||
- name: default
|
||||
database: test_db
|
||||
duration: 1d
|
||||
default: true
|
||||
```
|
||||
|
||||
* `influxdb_api_user` - set the api user if you have enabled http authentification (default: `admin`)
|
||||
* `influxdb_api_password` - set the api password if you have enabled http authentification
|
||||
* `influxdb_api_port` - set the api port (default: `8086`)
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
---
|
||||
influxdb_databases: []
|
||||
influxdb_users: []
|
||||
influxdb_api_user: admin
|
||||
influxdb_api_port: 8086
|
||||
influxdb_default_config:
|
||||
|
@ -11,3 +9,6 @@ influxdb_default_config:
|
|||
wal-dir: /var/lib/influxdb/wal
|
||||
influxdb_config: {}
|
||||
influxdb_full_config: '{{ influxdb_default_config|combine(influxdb_config) }}'
|
||||
influxdb_databases: []
|
||||
influxdb_policies: []
|
||||
influxdb_users: []
|
||||
|
|
|
@ -18,6 +18,11 @@
|
|||
state: absent
|
||||
influxdb_databases:
|
||||
- test_db
|
||||
influxdb_retention_policies:
|
||||
- name: default
|
||||
database: test_db
|
||||
duration: 1d
|
||||
default: true
|
||||
influxdb_config:
|
||||
'[collectd]':
|
||||
enabled: true
|
||||
|
|
|
@ -37,6 +37,11 @@ def test_databases(host):
|
|||
assert cmd.succeeded
|
||||
assert 'test_db' in cmd.stdout
|
||||
|
||||
def test_databases(host):
|
||||
cmd = host.run('influx -execute "SHOW RETENTION POLICIES ON test_db"')
|
||||
assert cmd.succeeded
|
||||
assert re.search(r'default\s+24h0m0s\s+1h0m0s\s+1\s+true', cmd.stdout)
|
||||
|
||||
def test_grants(host):
|
||||
cmd = host.run('influx -execute "SHOW GRANTS FOR test"')
|
||||
assert cmd.succeeded
|
||||
|
|
|
@ -30,6 +30,18 @@
|
|||
loop: '{{ influxdb_databases }}'
|
||||
tags: influxdb
|
||||
|
||||
- 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
|
||||
|
||||
- name: create users
|
||||
community.general.influxdb_user:
|
||||
user_name: '{{ item.name }}'
|
||||
|
|
Loading…
Reference in a new issue