diff --git a/.github/workflows/role-icingaweb2.yml b/.github/workflows/role-icingaweb2.yml new file mode 100644 index 00000000..67bd2149 --- /dev/null +++ b/.github/workflows/role-icingaweb2.yml @@ -0,0 +1,63 @@ +--- +name: Empty role-icingaweb2 +on: + push: + tags: + - '*' + branches: + - main + - 'feature/**' + - 'fix/**' + - '!doc/**' + paths: + - roles/icingaweb2/** + - molecule/role-icingaweb2/** + pull_request: + branches: + - 'feature/**' + - 'fix/**' + - '!doc/**' + +jobs: + icingaweb2-ansible-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-icingaweb2] + + 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-icingaweb2/collections.yml b/molecule/role-icingaweb2/collections.yml new file mode 100644 index 00000000..66cb0953 --- /dev/null +++ b/molecule/role-icingaweb2/collections.yml @@ -0,0 +1,5 @@ +collections: + - name: community.mysql + - name: community.docker + - name: community.general + version: ">=2,<3" diff --git a/molecule/role-icingaweb2/converge.yml b/molecule/role-icingaweb2/converge.yml new file mode 100644 index 00000000..63ac7133 --- /dev/null +++ b/molecule/role-icingaweb2/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: icingaweb2 diff --git a/molecule/role-icingaweb2/dependency.yml b/molecule/role-icingaweb2/dependency.yml new file mode 100644 index 00000000..9810d54a --- /dev/null +++ b/molecule/role-icingaweb2/dependency.yml @@ -0,0 +1,4 @@ +dependency: + name: galaxy + options: + role-file: requirements.yml diff --git a/molecule/role-icingaweb2/files/test.conf b/molecule/role-icingaweb2/files/test.conf new file mode 100644 index 00000000..62690e4e --- /dev/null +++ b/molecule/role-icingaweb2/files/test.conf @@ -0,0 +1,14 @@ +### Business Process Config File ### +# +# Title : test +# Description : test +# Owner : icinga +# AddToMenu : yes +# Statetype : soft +# +################################### + +test2 = +display 1;test2;test2 +webserver = +display 1;webserver;webserver diff --git a/molecule/role-icingaweb2/host_vars/icinga-default.yaml b/molecule/role-icingaweb2/host_vars/icinga-default.yaml new file mode 100644 index 00000000..e69de29b diff --git a/molecule/role-icingaweb2/molecule.yml b/molecule/role-icingaweb2/molecule.yml new file mode 100644 index 00000000..3f13ab2d --- /dev/null +++ b/molecule/role-icingaweb2/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-icingaweb2/prepare.yml b/molecule/role-icingaweb2/prepare.yml new file mode 100644 index 00000000..cc5bbc56 --- /dev/null +++ b/molecule/role-icingaweb2/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-icingaweb2/requirements.yml b/molecule/role-icingaweb2/requirements.yml new file mode 100644 index 00000000..cf94e2e2 --- /dev/null +++ b/molecule/role-icingaweb2/requirements.yml @@ -0,0 +1,2 @@ +roles: + - geerlingguy.mysql diff --git a/molecule/role-icingaweb2/verify.yml b/molecule/role-icingaweb2/verify.yml new file mode 100644 index 00000000..3c4ed28d --- /dev/null +++ b/molecule/role-icingaweb2/verify.yml @@ -0,0 +1,9 @@ +--- + +- name: Verify + hosts: all + tasks: + - name: Check for running icinga2 + service: + name: icinga2 + state: started diff --git a/requirements-test-2.16.2.txt b/requirements-test-2.16.2.txt new file mode 100644 index 00000000..9332828e --- /dev/null +++ b/requirements-test-2.16.2.txt @@ -0,0 +1,5 @@ +ansible-core==2.16.2 +ansible-lint +molecule +molecule-docker +pytest-testinfra