Skip to content

Commit

Permalink
Merge pull request #5 from tbauriedel/feature/add-role-influxdb
Browse files Browse the repository at this point in the history
Feature/add role influxdb
  • Loading branch information
tbauriedel authored Dec 28, 2023
2 parents 74e0087 + 86fe8bf commit c61d1b2
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

Collection to manage InfluxDB repository and setup.

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).

It was created with the aim of refreshing my Ansible knowledge and getting in touch with Collections. Any hints for improvements are therefore welcome.

## Supported systems
Expand All @@ -15,4 +17,4 @@ It was created with the aim of refreshing my Ansible knowledge and getting in to
## Roles

* repos
* influxdb (TODO)
* influxdb
2 changes: 2 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Vagrant.configure("2") do |config|
config.vm.define "ubuntu" do |ubuntu|
ubuntu.vm.hostname = "influxdb-ubuntu"
ubuntu.vm.box = "bento/ubuntu-22.04"
ubuntu.vm.network "forwarded_port", guest: 8086, host: 8086
ubuntu.vm.provision "ansible" do |ansible|
ansible.playbook = "vagrant-tests.yml"
end
Expand All @@ -13,6 +14,7 @@ Vagrant.configure("2") do |config|
config.vm.define "centos" do |centos|
centos.vm.hostname = "influxdb-centos"
centos.vm.box = "eurolinux-vagrant/centos-stream-9"
centos.vm.network "forwarded_port", guest: 8086, host: 8087
centos.vm.provision "ansible" do |ansible|
ansible.playbook = "vagrant-tests.yml"
end
Expand Down
9 changes: 9 additions & 0 deletions roles/influxdb/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
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: ""
5 changes: 5 additions & 0 deletions roles/influxdb/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- name: Restart InfluxDB
ansible.builtin.service:
name: influxdb
state: restarted
15 changes: 15 additions & 0 deletions roles/influxdb/tasks/install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
- name: Ensure InfluxDB packages are installed
ansible.builtin.package:
name: "{{ item }}"
state: present
loop: "{{ influxdb_influxdb_packages }}"
notify: Restart InfluxDB

- name: Ensure startup config is there
ansible.builtin.template:
src: config.toml.j2
dest: /etc/influxdb/config.toml
mode: 0644
owner: root
group: root
13 changes: 13 additions & 0 deletions roles/influxdb/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
- name: Include OS specific vars
ansible.builtin.include_vars: "{{ lookup('first_found', params) }}"
vars:
params:
files:
- "{{ ansible_os_family }}.yml"
- default.yml
paths:
- "{{ role_path }}/vars"

- name: Include installation
ansible.builtin.include_tasks: install.yml
6 changes: 6 additions & 0 deletions roles/influxdb/templates/config.toml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# {{ ansible_managed }}

bolt-path = {{ influxdb_influxdb_bolt_path }}
engine-path = {{ influxdb_influxdb_engine_path }}

{{ redis_extra_config }}
1 change: 1 addition & 0 deletions roles/influxdb/vars/Debian.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
1 change: 1 addition & 0 deletions roles/influxdb/vars/RedHat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
2 changes: 2 additions & 0 deletions roles/influxdb/vars/default.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
# default vars for influxdb.influxdb
1 change: 1 addition & 0 deletions vagrant-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@

roles:
- repos
- influxdb

0 comments on commit c61d1b2

Please sign in to comment.