From 0426b95a1013fd81add5f4007615231768d2816f Mon Sep 17 00:00:00 2001 From: Thilo W Date: Thu, 18 Jan 2024 09:43:36 +0100 Subject: [PATCH] add tests for empty role-icingadb --- .github/workflows/role-icingadb.yml | 66 +++++++++++++++++++ molecule/role-icingadb/collections.yml | 5 ++ molecule/role-icingadb/converge.yml | 12 ++++ molecule/role-icingadb/dependency.yml | 4 ++ .../host_vars/icinga-default.yaml | 0 molecule/role-icingadb/molecule.yml | 26 ++++++++ molecule/role-icingadb/prepare.yml | 11 ++++ molecule/role-icingadb/requirements.yml | 2 + 8 files changed, 126 insertions(+) create mode 100644 .github/workflows/role-icingadb.yml create mode 100644 molecule/role-icingadb/collections.yml create mode 100644 molecule/role-icingadb/converge.yml create mode 100644 molecule/role-icingadb/dependency.yml create mode 100644 molecule/role-icingadb/host_vars/icinga-default.yaml create mode 100644 molecule/role-icingadb/molecule.yml create mode 100644 molecule/role-icingadb/prepare.yml create mode 100644 molecule/role-icingadb/requirements.yml diff --git a/.github/workflows/role-icingadb.yml b/.github/workflows/role-icingadb.yml new file mode 100644 index 00000000..5aa2e664 --- /dev/null +++ b/.github/workflows/role-icingadb.yml @@ -0,0 +1,66 @@ +--- + # These Jobs should be always be run against the latest version of ansible on the systems + # Feel free to update python and ansible versions + # + # In addition to keep them quick and no additional variables are used. + # +name: role-icingadb +on: + push: + branches: + - main + - 'feature/**' + - 'fix/**' + - '!doc/**' + paths: + - roles/icingadb/** + - molecule/role-icingadb/** + pull_request: + branches: + - 'feature/**' + - 'fix/**' + - '!doc/**' + +jobs: + icingadb_latest: + runs-on: ubuntu-latest + + env: + COLLECTION_NAMESPACE: icinga + COLLECTION_NAME: icinga + + strategy: + fail-fast: false + max-parallel: 1 + matrix: + distro: [ubuntu2204] + python: ['3.10'] + ansible: ['2.16.2'] + scenario: [role-icingadb] + + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + + - name: Install dependencies ansible + run: | + python3 -m pip install --upgrade pip + python3 -m pip install -r requirements-test-${{ matrix.ansible }}.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 }} diff --git a/molecule/role-icingadb/collections.yml b/molecule/role-icingadb/collections.yml new file mode 100644 index 00000000..66cb0953 --- /dev/null +++ b/molecule/role-icingadb/collections.yml @@ -0,0 +1,5 @@ +collections: + - name: community.mysql + - name: community.docker + - name: community.general + version: ">=2,<3" diff --git a/molecule/role-icingadb/converge.yml b/molecule/role-icingadb/converge.yml new file mode 100644 index 00000000..ac6756e4 --- /dev/null +++ b/molecule/role-icingadb/converge.yml @@ -0,0 +1,12 @@ +--- + +- name: Converge + hosts: all + collections: + - icinga.icinga + pre_tasks: + - ansible.builtin.include_role: + name: repos + post_tasks: + - ansible.builtin.include_role: + name: icingadb diff --git a/molecule/role-icingadb/dependency.yml b/molecule/role-icingadb/dependency.yml new file mode 100644 index 00000000..9810d54a --- /dev/null +++ b/molecule/role-icingadb/dependency.yml @@ -0,0 +1,4 @@ +dependency: + name: galaxy + options: + role-file: requirements.yml diff --git a/molecule/role-icingadb/host_vars/icinga-default.yaml b/molecule/role-icingadb/host_vars/icinga-default.yaml new file mode 100644 index 00000000..e69de29b diff --git a/molecule/role-icingadb/molecule.yml b/molecule/role-icingadb/molecule.yml new file mode 100644 index 00000000..3f13ab2d --- /dev/null +++ b/molecule/role-icingadb/molecule.yml @@ -0,0 +1,26 @@ +--- +dependency: + name: galaxy +driver: + name: docker +platforms: + - name: icinga-default + image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2204}-ansible:latest" + command: ${MOLECULE_DOCKER_COMMAND:-""} + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:rw + cgroupns_mode: host + privileged: true + pre_build_image: true +provisioner: + name: ansible + inventory: + link: + host_vars: host_vars/ +verifier: + name: testinfra + directory: tests/integration/ +lint: | + set -e + yamllint --no-warnings roles/ + ansible-lint roles/ diff --git a/molecule/role-icingadb/prepare.yml b/molecule/role-icingadb/prepare.yml new file mode 100644 index 00000000..cc5bbc56 --- /dev/null +++ b/molecule/role-icingadb/prepare.yml @@ -0,0 +1,11 @@ +--- +- name: Prepare + hosts: all + tasks: + - name: Install requirements for Debian + apt: + name: + - gpg + - apt-transport-https + update_cache: yes + when: ansible_os_family == "Debian" diff --git a/molecule/role-icingadb/requirements.yml b/molecule/role-icingadb/requirements.yml new file mode 100644 index 00000000..cf94e2e2 --- /dev/null +++ b/molecule/role-icingadb/requirements.yml @@ -0,0 +1,2 @@ +roles: + - geerlingguy.mysql