Skip to content

Commit

Permalink
molecule test and github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
zerwes committed Nov 14, 2024
1 parent eec3ff0 commit 107fc15
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
53 changes: 53 additions & 0 deletions .github/workflows/molecule.yml
Original file line number Diff line number Diff line change
@@ -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 }}
8 changes: 8 additions & 0 deletions molecule/README.md
Original file line number Diff line number Diff line change
@@ -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`
31 changes: 31 additions & 0 deletions molecule/default/Dockerfile-debian11.j2
Original file line number Diff line number Diff line change
@@ -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" ]
31 changes: 31 additions & 0 deletions molecule/default/Dockerfile-debian12.j2
Original file line number Diff line number Diff line change
@@ -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" ]
7 changes: 7 additions & 0 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- name: Converge
hosts: all
tasks:
- name: "rundeck"
include_role:
name: "ansible-role-rundeck"
23 changes: 23 additions & 0 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions molecule/default/testdnsbl.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
repo.zero-sys.net
dap.zero-sys.net

0 comments on commit 107fc15

Please sign in to comment.