Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
tbauriedel committed Jan 12, 2024
2 parents db417ec + 2f48d0d commit f4dda9c
Show file tree
Hide file tree
Showing 16 changed files with 103 additions and 103 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
![Lint](https://github.com/tbauriedel/ansible-collection-influxdb/actions/workflows/yamllint.yml/badge.svg)
![Lint](https://github.com/tbauriedel/ansible-collection-influxdb2/actions/workflows/yamllint.yml/badge.svg)

> **Note:** Collection is work in progress
# ansible-collection-influxdb
# ansible-collection-influxdb2

Ansible collection to manage [InfluxDB](https://www.influxdata.com/) repository and setup.
Read more about InfluxDB in the [official documentation](https://docs.influxdata.com/influxdb/v2/).
Ansible collection to manage [InfluxDBv2](https://www.influxdata.com/) repository and setup.
Read more about InfluxDBv2 in the [official documentation](https://docs.influxdata.com/influxdb/v2/).

The collection is still at a very experimental stage and is growing bit by bit according to my use cases. New configuration options will be implemented when they are needed. If you already have requests, please let me know via issue (or pull request).

Expand All @@ -14,32 +14,32 @@ It was created with the aim of refreshing my Ansible knowledge and getting in to
## Roles

* [Role: repos](roles/repos/README.md) - Install the official InfluxDb repositories
* [Role: influxdb](roles/influxdb/README.md) - Install and configure InfluxDB
* [Role: influxdb2](roles/influxdb2/README.md) - Install and configure InfluxDBv2

## Example

```
- hosts: all
become: true
vars:
influxdb_influxdb_admin_token: 12345678abcdefg
influxdb_influxdb_buckets:
influxdb_influxdb2_admin_token: 12345678abcdefg
influxdb_influxdb2_buckets:
- name: foobar1
state: absent
org: default
token: "{{ influxdb_influxdb_admin_token }}"
host: "{{ influxdb_influxdb_host }}"
token: "{{ influxdb_influxdb2admin_token }}"
host: "{{ influxdb_influxdb2_host }}"
retention:
type: 'expire'
everySeconds: '50000'
shardGroupDurationSeconds: '0'
collections:
tbauriedel.influxdb
tbauriedel.influxdb2
roles:
- repos
- influxdb
- influxdb2
```

## Supported systems
Expand Down
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace: tbauriedel
name: influxdb
name: influxdb2
version: 0.0.0
readme: README.md
authors:
Expand Down
46 changes: 0 additions & 46 deletions roles/influxdb/README.md

This file was deleted.

20 changes: 0 additions & 20 deletions roles/influxdb/defaults/main.yml

This file was deleted.

6 changes: 0 additions & 6 deletions roles/influxdb/templates/config.toml.j2

This file was deleted.

46 changes: 46 additions & 0 deletions roles/influxdb2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# influxdb.influxdb2

## Description

With that role you can install and configure InfluxDBv2.
At the moment the configuration is very basic. Over time, this role will be expanded.

## Variables

**Configuration:**
* `influxdb_influxdb2_bolt_path`: InfluxDB bolt-path
* `influxdb_influxdb2_engine_path`: InfluxDB engine-path
* `influxdb_influxdb2_extra_config`: Some extra configuration

**Setup:**
* `influxdb_influxdb2_host`: HTTP address of InfluxDB (default: 'http://localhost:8086')
* `influxdb_influxdb2_primary_user.name`: Username for primary administrative user (default: 'admin')
* `influxdb_influxdb2_primary_user.password`: Password for primary administrative user (default: 'ChangeMe123!')
* `influxdb_influxdb2_primary_org`: Primary organization (default: 'default')
* `influxdb_influxdb2_primary_bucket`: Primary bucket (default: 'default')
* `influxdb_influxdb2_retention`: Retention for primary bucket (default: '0')
* `influxdb_influxdb2_admin_token`: Admin API token created in the setup (default: 'Random123ChangeMe!')

**Buckets**
* `influxdb_influxdb2_buckets`: List of buckets to manage
* `name`: Name of bucket. (watch [bucket naming restrictions](https://docs.influxdata.com/influxdb/v2/admin/buckets/create-bucket/?t=InfluxDB+API#bucket-naming-restrictions))
* `state`: state of bucket ('present' or 'absent')
* `org`: InfluxDB organization name
* `token`: API token to manage the bucket
* `retention`: List of retention rules containing a single object with the following fields
* `type`: expire
* `everySeconds`: Number of seconds to retain data (0 means forever)
* `shardGroupDurationSeconds`: Number of seconds to retain shard groups (0 means forever)

Defaults can be viewed in vars/defaults.yml

## Example

Install the official InfluxDB repository:
```
- hosts: all
become: true
roles:
- influxdb2
```
20 changes: 20 additions & 0 deletions roles/influxdb2/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
influxdb_influxdb2_packages:
- influxdb2
- influxdb2-cli

influxdb_influxdb2_bolt_path: /var/lib/influxdb/influxd.bolt
influxdb_influxdb2_engine_path: /var/lib/influxdb/engine

influxdb_influxdb2_extra_config: ""

influxdb_influxdb2_host: http://localhost:8086
influxdb_influxdb2_primary_user:
name: admin
password: ChangeMe123!
influxdb_influxdb2_primary_org: default
influxdb_influxdb2_primary_bucket: default
influxdb_influxdb2_admin_token: "Random123ChangeMe!"
influxdb_influxdb2_retention: 0

influxdb_influxdb2_buckets: []
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
ansible.builtin.package:
name: "{{ item }}"
state: present
loop: "{{ influxdb_influxdb_packages }}"
loop: "{{ influxdb_influxdb2_packages }}"
notify: Restart InfluxDB

- name: Ensure startup config is there
Expand Down
File renamed without changes.
22 changes: 11 additions & 11 deletions roles/influxdb/tasks/setup.yml → roles/influxdb2/tasks/setup.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
---
- name: Ensure admin setup token is definded
ansible.builtin.fail:
msg: Variable influxdb_influxdb_admin_token is not defined in variables
when: influxdb_influxdb_admin_token == ""
msg: Variable influxdb_influxdb2_admin_token is not defined in variables
when: influxdb_influxdb2_admin_token == ""

- name: Ensure InfluxDB is set up
ansible.builtin.command: influx setup \
--host "{{ influxdb_influxdb_host }}" \
--username "{{ influxdb_influxdb_primary_user.name }}" \
--password "{{ influxdb_influxdb_primary_user.password }}" \
--org "{{ influxdb_influxdb_primary_org }}" \
--bucket "{{ influxdb_influxdb_primary_bucket }}" \
--retention "{{ influxdb_influxdb_retention }}" \
--token "{{ influxdb_influxdb_admin_token }}" \
--host "{{ influxdb_influxdb2_host }}" \
--username "{{ influxdb_influxdb2_primary_user.name }}" \
--password "{{ influxdb_influxdb2_primary_user.password }}" \
--org "{{ influxdb_influxdb2_primary_org }}" \
--bucket "{{ influxdb_influxdb2_primary_bucket }}" \
--retention "{{ influxdb_influxdb2_retention }}" \
--token "{{ influxdb_influxdb2_admin_token }}" \
--force
register: _influx_setup
failed_when:
Expand All @@ -27,9 +27,9 @@
state: "{{ item.state }}"
org: "{{ item.org }}"
token: "{{ item.token }}"
host: "{{ influxdb_influxdb_host }}"
host: "{{ influxdb_influxdb2_host }}"
retention:
type: "{{ item.retention.type }}"
everySeconds: "{{ item.retention.everySeconds }}"
shardGroupDurationSeconds: "{{ item.retention.shardGroupDurationSeconds }}"
loop: "{{ influxdb_influxdb_buckets }}"
loop: "{{ influxdb_influxdb2_buckets }}"
6 changes: 6 additions & 0 deletions roles/influxdb2/templates/config.toml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# {{ ansible_managed }}

bolt-path = "{{ influxdb_influxdb2_bolt_path }}"
engine-path = "{{ influxdb_influxdb2_engine_path }}"

{{ influxdb_influxdb2_extra_config }}
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 7 additions & 7 deletions vagrant/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
- hosts: all
become: true
vars:
influxdb_influxdb_admin_token: 12345678abcdefg
influxdb_influxdb_buckets:
influxdb_influxdb2_admin_token: 12345678abcdefg
influxdb_influxdb2_buckets:
- name: foobar1
state: absent
state: present
org: default
token: "{{ influxdb_influxdb_admin_token }}"
host: "{{ influxdb_influxdb_host }}"
token: "{{ influxdb_influxdb2_admin_token }}"
host: "{{ influxdb_influxdb2_host }}"
retention:
type: 'expire'
everySeconds: 50000
shardGroupDurationSeconds: 0

collections:
- tbauriedel.influxdb
- tbauriedel.influxdb2

roles:
- repos
# - influxdb
- influxdb2

0 comments on commit f4dda9c

Please sign in to comment.