From 12c59f53ac34e3d3a37ae28f765b3ff2120f2068 Mon Sep 17 00:00:00 2001 From: Tobias Bauriedel Date: Fri, 12 Jan 2024 08:49:18 +0100 Subject: [PATCH] Rename to InfluxDBv2 --- README.md | 22 ++++----- galaxy.yml | 2 +- roles/influxdb/README.md | 46 ------------------- roles/influxdb/defaults/main.yml | 20 -------- roles/influxdb/templates/config.toml.j2 | 6 --- roles/influxdb2/README.md | 46 +++++++++++++++++++ roles/influxdb2/defaults/main.yml | 20 ++++++++ .../{influxdb => influxdb2}/handlers/main.yml | 0 .../{influxdb => influxdb2}/tasks/install.yml | 2 +- roles/{influxdb => influxdb2}/tasks/main.yml | 0 roles/{influxdb => influxdb2}/tasks/setup.yml | 22 ++++----- roles/influxdb2/templates/config.toml.j2 | 6 +++ roles/{influxdb => influxdb2}/vars/Debian.yml | 0 roles/{influxdb => influxdb2}/vars/RedHat.yml | 0 .../{influxdb => influxdb2}/vars/default.yml | 0 vagrant/playbook.yml | 14 +++--- 16 files changed, 103 insertions(+), 103 deletions(-) delete mode 100644 roles/influxdb/README.md delete mode 100644 roles/influxdb/defaults/main.yml delete mode 100644 roles/influxdb/templates/config.toml.j2 create mode 100644 roles/influxdb2/README.md create mode 100644 roles/influxdb2/defaults/main.yml rename roles/{influxdb => influxdb2}/handlers/main.yml (100%) rename roles/{influxdb => influxdb2}/tasks/install.yml (90%) rename roles/{influxdb => influxdb2}/tasks/main.yml (100%) rename roles/{influxdb => influxdb2}/tasks/setup.yml (55%) create mode 100644 roles/influxdb2/templates/config.toml.j2 rename roles/{influxdb => influxdb2}/vars/Debian.yml (100%) rename roles/{influxdb => influxdb2}/vars/RedHat.yml (100%) rename roles/{influxdb => influxdb2}/vars/default.yml (100%) diff --git a/README.md b/README.md index 0b02a81..761447d 100644 --- a/README.md +++ b/README.md @@ -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). @@ -14,7 +14,7 @@ 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 @@ -22,24 +22,24 @@ It was created with the aim of refreshing my Ansible knowledge and getting in to - 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 diff --git a/galaxy.yml b/galaxy.yml index a0ab6ea..7df9598 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -1,5 +1,5 @@ namespace: tbauriedel -name: influxdb +name: influxdb2 version: 0.0.0 readme: README.md authors: diff --git a/roles/influxdb/README.md b/roles/influxdb/README.md deleted file mode 100644 index 84f55c5..0000000 --- a/roles/influxdb/README.md +++ /dev/null @@ -1,46 +0,0 @@ -# influxdb.influxdb - -## Description - -With that role you can install and configure InfluxDB. -At the moment the configuration is very basic. Over time, this role will be expanded. - -## Variables - -**Configuration:** -* `influxdb_influxdb_bolt_path`: InfluxDB bolt-path -* `influxdb_influxdb_engine_path`: InfluxDB engine-path -* `influxdb_influxdb_extra_config`: Some extra configuration - -**Setup:** -* `influxdb_influxdb_host`: HTTP address of InfluxDB (default: 'http://localhost:8086') -* `influxdb_influxdb_primary_user.name`: Username for primary administrative user (default: 'admin') -* `influxdb_influxdb_primary_user.password`: Password for primary administrative user (default: 'ChangeMe123!') -* `influxdb_influxdb_primary_org`: Primary organization (default: 'default') -* `influxdb_influxdb_primary_bucket`: Primary bucket (default: 'default') -* `influxdb_influxdb_retention`: Retention for primary bucket (default: '0') -* `influxdb_influxdb_admin_token`: Admin API token created in the setup (default: 'Random123ChangeMe!') - -**Buckets** -* `influxdb_influxdb_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: - - influxdb -``` \ No newline at end of file diff --git a/roles/influxdb/defaults/main.yml b/roles/influxdb/defaults/main.yml deleted file mode 100644 index 2b8c8c7..0000000 --- a/roles/influxdb/defaults/main.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- -influxdb_influxdb_packages: - - influxdb2 - - influxdb2-cli - -influxdb_influxdb_bolt_path: /var/lib/influxdb/influxd.bolt -influxdb_influxdb_engine_path: /var/lib/influxdb/engine - -influxdb_influxdb_extra_config: "" - -influxdb_influxdb_host: http://localhost:8086 -influxdb_influxdb_primary_user: - name: admin - password: ChangeMe123! -influxdb_influxdb_primary_org: default -influxdb_influxdb_primary_bucket: default -influxdb_influxdb_admin_token: "Random123ChangeMe!" -influxdb_influxdb_retention: 0 - -influxdb_influxdb_buckets: [] diff --git a/roles/influxdb/templates/config.toml.j2 b/roles/influxdb/templates/config.toml.j2 deleted file mode 100644 index 6e9df08..0000000 --- a/roles/influxdb/templates/config.toml.j2 +++ /dev/null @@ -1,6 +0,0 @@ -# {{ ansible_managed }} - -bolt-path = "{{ influxdb_influxdb_bolt_path }}" -engine-path = "{{ influxdb_influxdb_engine_path }}" - -{{ influxdb_influxdb_extra_config }} \ No newline at end of file diff --git a/roles/influxdb2/README.md b/roles/influxdb2/README.md new file mode 100644 index 0000000..0dcd910 --- /dev/null +++ b/roles/influxdb2/README.md @@ -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 +``` \ No newline at end of file diff --git a/roles/influxdb2/defaults/main.yml b/roles/influxdb2/defaults/main.yml new file mode 100644 index 0000000..8af2eac --- /dev/null +++ b/roles/influxdb2/defaults/main.yml @@ -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: [] diff --git a/roles/influxdb/handlers/main.yml b/roles/influxdb2/handlers/main.yml similarity index 100% rename from roles/influxdb/handlers/main.yml rename to roles/influxdb2/handlers/main.yml diff --git a/roles/influxdb/tasks/install.yml b/roles/influxdb2/tasks/install.yml similarity index 90% rename from roles/influxdb/tasks/install.yml rename to roles/influxdb2/tasks/install.yml index 1c71c77..02ff6a0 100644 --- a/roles/influxdb/tasks/install.yml +++ b/roles/influxdb2/tasks/install.yml @@ -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 diff --git a/roles/influxdb/tasks/main.yml b/roles/influxdb2/tasks/main.yml similarity index 100% rename from roles/influxdb/tasks/main.yml rename to roles/influxdb2/tasks/main.yml diff --git a/roles/influxdb/tasks/setup.yml b/roles/influxdb2/tasks/setup.yml similarity index 55% rename from roles/influxdb/tasks/setup.yml rename to roles/influxdb2/tasks/setup.yml index 1ab7bc8..3fba242 100644 --- a/roles/influxdb/tasks/setup.yml +++ b/roles/influxdb2/tasks/setup.yml @@ -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: @@ -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 }}" diff --git a/roles/influxdb2/templates/config.toml.j2 b/roles/influxdb2/templates/config.toml.j2 new file mode 100644 index 0000000..94671a8 --- /dev/null +++ b/roles/influxdb2/templates/config.toml.j2 @@ -0,0 +1,6 @@ +# {{ ansible_managed }} + +bolt-path = "{{ influxdb_influxdb2_bolt_path }}" +engine-path = "{{ influxdb_influxdb2_engine_path }}" + +{{ influxdb_influxdb2_extra_config }} \ No newline at end of file diff --git a/roles/influxdb/vars/Debian.yml b/roles/influxdb2/vars/Debian.yml similarity index 100% rename from roles/influxdb/vars/Debian.yml rename to roles/influxdb2/vars/Debian.yml diff --git a/roles/influxdb/vars/RedHat.yml b/roles/influxdb2/vars/RedHat.yml similarity index 100% rename from roles/influxdb/vars/RedHat.yml rename to roles/influxdb2/vars/RedHat.yml diff --git a/roles/influxdb/vars/default.yml b/roles/influxdb2/vars/default.yml similarity index 100% rename from roles/influxdb/vars/default.yml rename to roles/influxdb2/vars/default.yml diff --git a/vagrant/playbook.yml b/vagrant/playbook.yml index d11f61b..b2bb34e 100644 --- a/vagrant/playbook.yml +++ b/vagrant/playbook.yml @@ -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