feat: added molecule tests
Some checks failed
Molecule Tests / molecule-tests (pull_request) Failing after 1m52s
Some checks failed
Molecule Tests / molecule-tests (pull_request) Failing after 1m52s
This commit is contained in:
43
.gitea/workflows/molecule-tests.yml
Normal file
43
.gitea/workflows/molecule-tests.yml
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
#SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
---
|
||||||
|
name: Molecule Tests
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 7 * * 1' # Every Monday at 07:00 UTC
|
||||||
|
workflow_dispatch:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
molecule-tests:
|
||||||
|
runs-on: fedora-latest
|
||||||
|
steps:
|
||||||
|
- name: Add ~/.local/bin to PATH
|
||||||
|
run: echo "$HOME/.local/bin" >> "$GITEA_PATH"
|
||||||
|
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
path: ansible_role_mail
|
||||||
|
|
||||||
|
- name: Install Molecule
|
||||||
|
run: pip install ansible molecule molecule-plugins[podman]
|
||||||
|
|
||||||
|
- name: Install Ansible collections
|
||||||
|
run: ansible-galaxy collection install containers.podman
|
||||||
|
|
||||||
|
- name: Run Molecule tests
|
||||||
|
working-directory: ansible_role_mail
|
||||||
|
run: molecule test
|
||||||
|
|
||||||
|
- name: Tag latest
|
||||||
|
if: github.ref == 'refs/heads/main'
|
||||||
|
working-directory: ansible_role_mail
|
||||||
|
run: |
|
||||||
|
git config user.name "giabot"
|
||||||
|
git config user.email "bot@mail.gianet.us"
|
||||||
|
git remote set-url origin "https://giabot:${{ secrets.GITEA_TOKEN }}@gianet.us/engineering/ansible_role_mail.git"
|
||||||
|
git tag -f latest
|
||||||
|
git push -f origin latest
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
galaxy_info:
|
galaxy_info:
|
||||||
role_name: "mailserver"
|
role_name: "mailserver"
|
||||||
|
namespace: "gianet"
|
||||||
author: "Luciano Giacchetta"
|
author: "Luciano Giacchetta"
|
||||||
description: "Complete Mail Server Role"
|
description: "Complete Mail Server Role"
|
||||||
company: "Giacchetta Networks LLC"
|
company: "Giacchetta Networks LLC"
|
||||||
|
|||||||
13
molecule/default/Dockerfile
Normal file
13
molecule/default/Dockerfile
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
FROM docker.io/library/debian:stable
|
||||||
|
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y --no-install-recommends \
|
||||||
|
python3 \
|
||||||
|
systemd \
|
||||||
|
systemd-sysv \
|
||||||
|
dbus \
|
||||||
|
ca-certificates && \
|
||||||
|
apt-get clean && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
CMD ["/usr/sbin/init"]
|
||||||
6
molecule/default/converge.yml
Normal file
6
molecule/default/converge.yml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
---
|
||||||
|
- name: Converge
|
||||||
|
hosts: all
|
||||||
|
roles:
|
||||||
|
- role: ansible_role_mail
|
||||||
64
molecule/default/molecule.yml
Normal file
64
molecule/default/molecule.yml
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
#SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
---
|
||||||
|
dependency:
|
||||||
|
name: galaxy
|
||||||
|
options:
|
||||||
|
requirements-file: molecule/default/requirements.yml
|
||||||
|
|
||||||
|
driver:
|
||||||
|
name: podman
|
||||||
|
|
||||||
|
platforms:
|
||||||
|
- name: debian-stable
|
||||||
|
image: docker.io/library/debian:stable
|
||||||
|
pre_build_image: false
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
privileged: true
|
||||||
|
systemd: always
|
||||||
|
command: /usr/sbin/init
|
||||||
|
|
||||||
|
- name: debian-oldstable
|
||||||
|
image: docker.io/library/debian:oldstable
|
||||||
|
pre_build_image: false
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
privileged: true
|
||||||
|
systemd: always
|
||||||
|
command: /usr/sbin/init
|
||||||
|
|
||||||
|
- name: ubuntu-latest
|
||||||
|
image: docker.io/library/ubuntu:latest
|
||||||
|
pre_build_image: false
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
privileged: true
|
||||||
|
systemd: always
|
||||||
|
command: /usr/sbin/init
|
||||||
|
|
||||||
|
- name: ubuntu-jammy
|
||||||
|
image: docker.io/library/ubuntu:jammy
|
||||||
|
pre_build_image: false
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
privileged: true
|
||||||
|
systemd: always
|
||||||
|
command: /usr/sbin/init
|
||||||
|
|
||||||
|
provisioner:
|
||||||
|
name: ansible
|
||||||
|
env:
|
||||||
|
ANSIBLE_ROLES_PATH: "${MOLECULE_PROJECT_DIRECTORY}/.."
|
||||||
|
playbooks:
|
||||||
|
converge: converge.yml
|
||||||
|
verify: verify.yml
|
||||||
|
|
||||||
|
scenario:
|
||||||
|
test_sequence:
|
||||||
|
- dependency
|
||||||
|
- destroy
|
||||||
|
- syntax
|
||||||
|
- create
|
||||||
|
- converge
|
||||||
|
- idempotence
|
||||||
|
- verify
|
||||||
|
- destroy
|
||||||
|
|
||||||
|
verifier:
|
||||||
|
name: ansible
|
||||||
4
molecule/default/requirements.yml
Normal file
4
molecule/default/requirements.yml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
#SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
---
|
||||||
|
collections:
|
||||||
|
- name: containers.podman
|
||||||
37
molecule/default/verify.yml
Normal file
37
molecule/default/verify.yml
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
---
|
||||||
|
- name: Verify
|
||||||
|
hosts: all
|
||||||
|
tasks:
|
||||||
|
- name: Gather service facts
|
||||||
|
ansible.builtin.service_facts:
|
||||||
|
|
||||||
|
- name: Assert postfix service is present
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- "'postfix.service' in ansible_facts.services"
|
||||||
|
|
||||||
|
- name: Assert dovecot service is present
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- "'dovecot.service' in ansible_facts.services"
|
||||||
|
|
||||||
|
- name: Check postfix main.cf exists
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: /etc/postfix/main.cf
|
||||||
|
register: postfix_main_cf
|
||||||
|
|
||||||
|
- name: Assert postfix main.cf exists
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- postfix_main_cf.stat.exists
|
||||||
|
|
||||||
|
- name: Check dovecot.conf exists
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: /etc/dovecot/dovecot.conf
|
||||||
|
register: dovecot_conf
|
||||||
|
|
||||||
|
- name: Assert dovecot.conf exists
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- dovecot_conf.stat.exists
|
||||||
Reference in New Issue
Block a user