From 107fc15016ab1044f63f075ca58c6ab2aaafc856 Mon Sep 17 00:00:00 2001 From: Klaus Zerwes Date: Thu, 14 Nov 2024 10:50:34 +0100 Subject: [PATCH] molecule test and github actions --- .github/workflows/lint.yml | 15 +++++++ .github/workflows/molecule.yml | 53 +++++++++++++++++++++++++ molecule/README.md | 8 ++++ molecule/default/Dockerfile-debian11.j2 | 31 +++++++++++++++ molecule/default/Dockerfile-debian12.j2 | 31 +++++++++++++++ molecule/default/converge.yml | 7 ++++ molecule/default/molecule.yml | 23 +++++++++++ molecule/default/testdnsbl.txt | 2 + 8 files changed, 170 insertions(+) create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/molecule.yml create mode 100644 molecule/README.md create mode 100644 molecule/default/Dockerfile-debian11.j2 create mode 100644 molecule/default/Dockerfile-debian12.j2 create mode 100644 molecule/default/converge.yml create mode 100644 molecule/default/molecule.yml create mode 100644 molecule/default/testdnsbl.txt diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..d78daf4 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,15 @@ +--- +name: ansible-lint +on: + pull_request: + push: + schedule: + - cron: "25 6 * * 1" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: run ansible-lint + uses: ansible/ansible-lint@v24.9.2 diff --git a/.github/workflows/molecule.yml b/.github/workflows/molecule.yml new file mode 100644 index 0000000..c00ccbb --- /dev/null +++ b/.github/workflows/molecule.yml @@ -0,0 +1,53 @@ +--- +name: molecule test +on: + pull_request: + push: + schedule: + - cron: "10 6 * * 1" +jobs: + molecule: + name: ansible + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + ansible: + - latest + - pinned + - legacy + distro: + - debian11 + - debian12 + include: + - ansible: latest + pip3deps: 'dnspython ansible molecule "molecule-plugins[docker]" yamllint ansible-lint requests==2.31.0' + - ansible: pinned + pip3deps: 'dnspython "ansible==8.6.0" "molecule-plugins[docker]" "yamllint==1.32.0" "ansible-lint==6.22.0"' + - ansible: legacy + pip3deps: 'dnspython "ansible==2.9.27" "molecule[docker,lint]==3.2.3" "yamllint==1.24.2" "ansible-lint==4.2.0" "requests<2.29" "urllib3<2"' + steps: + - uses: actions/checkout@v4 + with: + path: 'ansible-role-rundeck' + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.9 + + - name: Install test dependencies. + run: pip3 install ${{ matrix.pip3deps }} + + - name: Install collections required on ansible 2.9 + run: ansible-galaxy collection install community.general + if: ${{ matrix.ansible == 'legacy' }} + + - name: run molecule tests + run: molecule test + working-directory: rls.unbound + env: + PY_COLORS: '1' + ANSIBLE_FORCE_COLOR: '1' + molecule_skip_rebuild_all: true + MOLECULE_DISTRO: ${{ matrix.distro }} diff --git a/molecule/README.md b/molecule/README.md new file mode 100644 index 0000000..819fbc5 --- /dev/null +++ b/molecule/README.md @@ -0,0 +1,8 @@ +# test + +`molecule test` + +## test rebuild all maps +this takes time and consumes power! + +`molecule_skip_rebuild_all=false molecule test --destroy never` diff --git a/molecule/default/Dockerfile-debian11.j2 b/molecule/default/Dockerfile-debian11.j2 new file mode 100644 index 0000000..264b7ad --- /dev/null +++ b/molecule/default/Dockerfile-debian11.j2 @@ -0,0 +1,31 @@ +# Molecule managed + +FROM debian:bullseye + +ENV container docker +ENV LC_ALL C +ENV DEBIAN_FRONTEND noninteractive +ENV LANG en_US.UTF-8 +ENV LANGUAGE en_US:en +ENV LC_ALL en_US.UTF-8 + +RUN apt-get update \ + && apt-get install -y python3 sudo bash ca-certificates iproute2 python3-apt aptitude systemd systemd-sysv locales \ + && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \ + && locale-gen en_US.UTF-8 \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +RUN rm -f /lib/systemd/system/multi-user.target.wants/* \ + /etc/systemd/system/*.wants/* \ + /lib/systemd/system/local-fs.target.wants/* \ + /lib/systemd/system/sockets.target.wants/*udev* \ + /lib/systemd/system/sockets.target.wants/*initctl* \ + /lib/systemd/system/sysinit.target.wants/systemd-tmpfiles-setup* \ + /lib/systemd/system/systemd-update-utmp* + +RUN systemctl set-default multi-user.target + +#VOLUME [ "/sys/fs/cgroup" ] + +CMD [ "/lib/systemd/systemd", "log-level=info", "unit=sysinit.target" ] diff --git a/molecule/default/Dockerfile-debian12.j2 b/molecule/default/Dockerfile-debian12.j2 new file mode 100644 index 0000000..a0eb8b1 --- /dev/null +++ b/molecule/default/Dockerfile-debian12.j2 @@ -0,0 +1,31 @@ +# Molecule managed + +FROM debian:bookworm + +ENV container docker +ENV LC_ALL C +ENV DEBIAN_FRONTEND noninteractive +ENV LANG en_US.UTF-8 +ENV LANGUAGE en_US:en +ENV LC_ALL en_US.UTF-8 + +RUN apt-get update \ + && apt-get install -y python3 sudo bash ca-certificates iproute2 python3-apt aptitude systemd systemd-sysv locales \ + && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \ + && locale-gen en_US.UTF-8 \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +RUN rm -f /lib/systemd/system/multi-user.target.wants/* \ + /etc/systemd/system/*.wants/* \ + /lib/systemd/system/local-fs.target.wants/* \ + /lib/systemd/system/sockets.target.wants/*udev* \ + /lib/systemd/system/sockets.target.wants/*initctl* \ + /lib/systemd/system/sysinit.target.wants/systemd-tmpfiles-setup* \ + /lib/systemd/system/systemd-update-utmp* + +RUN systemctl set-default multi-user.target + +#VOLUME [ "/sys/fs/cgroup" ] + +CMD [ "/lib/systemd/systemd", "log-level=info", "unit=sysinit.target" ] diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml new file mode 100644 index 0000000..a512aa5 --- /dev/null +++ b/molecule/default/converge.yml @@ -0,0 +1,7 @@ +--- +- name: Converge + hosts: all + tasks: + - name: "rundeck" + include_role: + name: "ansible-role-rundeck" diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml new file mode 100644 index 0000000..98db24a --- /dev/null +++ b/molecule/default/molecule.yml @@ -0,0 +1,23 @@ +--- +driver: + name: docker +platforms: + - name: instance + image: debian:${MOLECULE_DISTRO:-debian12} + dockerfile: Dockerfile-${MOLECULE_DISTRO:-debian12}.j2 + privileged: true + override_command: false + tmpfs: + - /run + - /run/lock + - /tmp + capabilities: + - SYS_ADMIN + security_opts: + - seccomp=unconfined + +provisioner: + name: ansible + +verifier: + name: ansible diff --git a/molecule/default/testdnsbl.txt b/molecule/default/testdnsbl.txt new file mode 100644 index 0000000..83b9cf6 --- /dev/null +++ b/molecule/default/testdnsbl.txt @@ -0,0 +1,2 @@ +repo.zero-sys.net +dap.zero-sys.net