Skip to content

Commit

Permalink
Add molecule test for repos
Browse files Browse the repository at this point in the history
  • Loading branch information
tbauriedel committed Jan 11, 2024
1 parent 40f67c5 commit a358d37
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 5 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/test_repos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
name: tbauriedel.influxdb.repos

on:
pull_request:
branches:
- '*'

jobs:
repos:
runs-on: ubuntu-latest

env:
COLLECTION_NAMESPACE: tbauriedel
COLLECTION_NAME: influxdb

strategy:
matrix:
distro: ['centos7']
scenario: ['repos']

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

- name: Install dependencies ansible
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 }}
3 changes: 3 additions & 0 deletions molecule/repos/collections.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
collections:
- name: community.docker
- name: ansible.posix
9 changes: 9 additions & 0 deletions molecule/repos/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
- name: Converge
hosts: all

collections:
- tbauriedel.influxdb

roles:
- repos
18 changes: 18 additions & 0 deletions molecule/repos/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: instance
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
8 changes: 8 additions & 0 deletions molecule/repos/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
- name: Verify
hosts: all
tasks:
- name: Try to install InfluxDBv2 from includes repos
ansible.builtin.yum:
name: influxdb2
state: present
2 changes: 2 additions & 0 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
ansible
ansible-lint
molecule
molecule-docker
11 changes: 9 additions & 2 deletions roles/repos/tasks/Debian.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
---
#- name: Apt - Add repositiory key
# ansible.builtin.apt_key:
# state: present
# url: "{{ influxdb_repos_key_url }}"

- name: Apt - Add repositiory key
ansible.builtin.apt_key:
state: present
ansible.builtin.get_url:
url: "{{ influxdb_repos_key_url }}"
dest: /etc/apt/trusted.gpg.d/influx.asc
mode: '0644'
force: true

- name: Apt - Add repository to list
ansible.builtin.apt_repository:
Expand Down
4 changes: 2 additions & 2 deletions vagrant/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ 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.box = "centos/7"
centos.vm.network "forwarded_port", guest: 8086, host: 8087
centos.vm.provision "ansible" do |ansible|
ansible.playbook = "playbook.yml"
# ansible.verbose = "vvv"
end
end
end
end
2 changes: 1 addition & 1 deletion vagrant/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@

roles:
- repos
- influxdb
# - influxdb

0 comments on commit a358d37

Please sign in to comment.