Skip to content

Commit

Permalink
add molecule test for carbonapi
Browse files Browse the repository at this point in the history
  • Loading branch information
tbauriedel committed Aug 16, 2024
1 parent ae23ec9 commit 287717a
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 2 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/molecule_carbonapi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
name: Test role carbonapi

on:
pull_request:
branches:
- '*'

jobs:
build:
runs-on: ubuntu-latest

env:
COLLECTION_NAMESPACE: tbauriedel
COLLECTION_NAME: gographite

strategy:
matrix:
distro: ['rockylinux8', 'ubuntu2204', 'debian12']
scenario: ['carbonapi']

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

- 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
- name: Install collection
run: |
mkdir -p ~/.ansible/collections/ansible_collections/$COLLECTION_NAMESPACE
cp -a ../ansible-collection-$COLLECTION_NAME ~/.ansible/collections/ansible_collections/$COLLECTION_NAMESPACE/$COLLECTION_NAME
- name: Test with molecule
run: |
ansible --version
molecule --version
molecule test -s ${{ matrix.scenario }}
env:
MOLECULE_DISTRO: ${{ matrix.distro }}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
![Lint](https://github.com/tbauriedel/ansible-collection-gographite/actions/workflows/linting.yml/badge.svg)

# ansible-role-gographite

Installs and configures [go-carbon](https://github.com/go-graphite/go-carbon) and [carbonapi](https://github.com/go-graphite/carbonapi).
Expand Down
9 changes: 9 additions & 0 deletions molecule/carbonapi/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
- name: Converge
hosts: all

collections:
- tbauriedel.gographite

roles:
- carbonapi
18 changes: 18 additions & 0 deletions molecule/carbonapi/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: carbonapi
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
9 changes: 9 additions & 0 deletions molecule/carbonapi/prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
- name: Prepare
hosts: all
tasks:

Check failure on line 4 in molecule/carbonapi/prepare.yml

View workflow job for this annotation

GitHub Actions / linting

4:9 [trailing-spaces] trailing spaces
- name: Install dependencies
ansible.builtin.package:
name: libcairo2
state: present
when: ansible_os_family == "Debian"
8 changes: 8 additions & 0 deletions molecule/carbonapi/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: carbonapi
state: started
7 changes: 5 additions & 2 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
ansible-core
ansible-core==2.16.3
ansible-lint
yamllint
yamllint
molecule
molecule-docker
requests
1 change: 1 addition & 0 deletions roles/carbonapi/tasks/setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
ansible.builtin.dnf:
name: "{{ _fetched_source.dest }}"
state: present
disable_gpg_check: true
when: ansible_os_family == 'RedHat'

- name: Ensure config-dir exists
Expand Down

0 comments on commit 287717a

Please sign in to comment.