Skip to content

Commit

Permalink
add molecule for influxdb2
Browse files Browse the repository at this point in the history
  • Loading branch information
tbauriedel committed Jan 15, 2024
1 parent 3d740bf commit 69373ea
Show file tree
Hide file tree
Showing 14 changed files with 83 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
name: tbauriedel.influxdb.repos
name: Build

on:
pull_request:
branches:
- '*'

jobs:
repos:
build:
runs-on: ubuntu-latest

env:
Expand All @@ -16,14 +16,19 @@ jobs:

strategy:
matrix:
distro: ['centos7', 'ubuntu2204']
scenario: ['repos']
distro: ['rockylinux9', 'ubuntu2204']
scenario: ['repos', 'influxdb2']

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install dependencies ansible
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements-test.txt
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/vagrant/.vagrant
/vagrant/.vagrant
.vscode
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ It was created with the aim of refreshing my Ansible knowledge and getting in to
| Distribution | Tested on |
|--------------|--------------|
| Ubuntu | 22.04 |
| Centos | 7 |
| Rocky | 9 |
3 changes: 3 additions & 0 deletions molecule/influxdb2/collections.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
collections:
- name: community.docker
- name: ansible.posix
23 changes: 23 additions & 0 deletions molecule/influxdb2/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
- name: Converge
hosts: all

vars:
influxdb_influxdb2_admin_token: 123456789abc!
influxdb_influxdb2_buckets:
- name: foobar1
state: present
org: default
token: "{{ influxdb_influxdb2_admin_token }}"
host: "{{ influxdb_influxdb2_host }}"
retention:
type: 'expire'
everySeconds: 50000
shardGroupDurationSeconds: 0

collections:
- tbauriedel.influxdb2

roles:
- repos
- influxdb2
18 changes: 18 additions & 0 deletions molecule/influxdb2/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: influxdb2
image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2204}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
privileged: true
pre_build_image: true
provisioner:
name: ansible
verifier:
name: ansible
7 changes: 7 additions & 0 deletions molecule/influxdb2/prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- name: Prepare
hosts: all
tasks:
- name: Ensure python3-requests is installed
ansible.builtin.pip:
name: requests
8 changes: 8 additions & 0 deletions molecule/influxdb2/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
- name: Verify
hosts: all
tasks:
- name: Ensure service is running
ansible.builtin.service:
name: influxdb
state: started
2 changes: 1 addition & 1 deletion molecule/repos/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dependency:
driver:
name: docker
platforms:
- name: instance
- name: "repos-${MOLECULE_DISTRO}"
image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2204}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
cgroupns_mode: host
Expand Down
4 changes: 3 additions & 1 deletion plugins/modules/organize_bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
# pylint: disable=missing-module-docstring

from ansible.module_utils.basic import AnsibleModule
from ansible_collections.tbauriedel.influxdb.plugins.module_utils.utils import (Influx2Api) # pylint: disable=import-error
from ansible_collections.tbauriedel.influxdb2.plugins.module_utils.utils import (
Influx2Api,
)

def run_module():
'''
Expand Down
2 changes: 1 addition & 1 deletion requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ansible
ansible-core==2.16.2
ansible-lint
molecule
molecule-docker
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
p
2 changes: 1 addition & 1 deletion roles/influxdb2/tasks/setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

# TODO add handling for orgs, buckets, etc.
- name: Organize buckets
tbauriedel.influxdb.organize_bucket:
tbauriedel.influxdb2.organize_bucket:
name: "{{ item.name }}"
state: "{{ item.state }}"
org: "{{ item.org }}"
Expand Down
10 changes: 5 additions & 5 deletions vagrant/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ Vagrant.configure("2") do |config|
end
end

config.vm.define "centos" do |centos|
centos.vm.hostname = "influxdb-centos"
centos.vm.box = "centos/7"
centos.vm.network "forwarded_port", guest: 8086, host: 8087
centos.vm.provision "ansible" do |ansible|
config.vm.define "rocky" do |rocky|
rocky.vm.hostname = "influxdb-rocky"
rocky.vm.box = "rockylinux/9"
rocky.vm.network "forwarded_port", guest: 8086, host: 8087
rocky.vm.provision "ansible" do |ansible|
ansible.playbook = "playbook.yml"
# ansible.verbose = "vvv"
end
Expand Down

0 comments on commit 69373ea

Please sign in to comment.