diff --git a/.github/workflows/ansible.yml b/.github/workflows/ansible.yml deleted file mode 100644 index 6f229aa..0000000 --- a/.github/workflows/ansible.yml +++ /dev/null @@ -1,40 +0,0 @@ ---- -# -# Ansible managed -# - -name: Ansible Molecule - -on: - push: - tags_ignore: - - '*' - pull_request: - schedule: - - cron: '28 15 13 * *' - -jobs: - lint: - runs-on: ubuntu-latest - steps: - - name: checkout - uses: actions/checkout@v4 - - name: molecule - uses: ansible/ansible-lint@main - test: - needs: - - lint - runs-on: ubuntu-latest - strategy: - fail-fast: false - steps: - - name: checkout - uses: actions/checkout@v4 - with: - path: "${{ github.repository }}" - - name: molecule - uses: robertdebock/molecule-action@6.0.1 - with: - options: "--parallel all" - env: - TOX_PARALLEL_NO_SPINNER: 1 diff --git a/.github/workflows/molecule.yml b/.github/workflows/molecule.yml new file mode 100644 index 0000000..6538215 --- /dev/null +++ b/.github/workflows/molecule.yml @@ -0,0 +1,59 @@ +--- +# +# Ansible managed +# + +name: Ansible Molecule + +on: + push: + tags_ignore: + - '*' + pull_request: + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v4 + - name: molecule + uses: ansible/ansible-lint@main + test: + needs: + - lint + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - image: ubuntu + tag: noble + - image: amazonlinux + tag: "2023" + - image: rockylinux + tag: "8" + steps: + - name: checkout + uses: actions/checkout@v4 + with: + path: "${{ github.repository }}" + + - name: Set up Python 3 + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + # we specify 2.16.11 for compatibility with amazonlinux:2 + - name: Install test dependencies + run: pip install molecule-docker docker requests==2.31.0 ansible-core==2.16.11 + + - name: molecule + run: molecule test + env: + PY_COLORS: '1' + ANSIBLE_FORCE_COLOR: '1' + image: "${{ matrix.image }}" + tag: "${{ matrix.tag }}" + working-directory: "${{ github.repository }}" + diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 7b06c2f..5673fbe 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -7,32 +7,11 @@ lint: | yamllint molecule/default/converge.yml ansible-lint molecule/default/converge.yml platforms: - - name: instance - image: centos:7 -# options: -# config-file: molecule/default/yaml-lint.yml -#platformsa: -# - name: ubuntu-bionic -# image: solita/ubuntu-systemd:bionic -# command: ${MOLECULE_DOCKER_COMMAND:-""} -# volumes: -# - /sys/fs/cgroup:/sys/fs/cgroup:ro -# pull: true -# privileged: true -# pre_build_image: true -# groups: -# - docker -# - name: centos -# image: milcom/centos7-systemd:latest -# privileged: true -# groups: -# - docker + - name: "ssl-cert-${image:-ubuntu}-${tag:-jammy}" + image: "${image:-ubuntu}:${tag:-jammy}" provisioner: name: ansible - config_options: - defaults: - stdout_callback: yaml - bin_ansible_callbacks: yes + log: False scenario: name: default verifier: diff --git a/molecule/requirements.txt b/molecule/requirements.txt index c0878f0..6528ccc 100644 --- a/molecule/requirements.txt +++ b/molecule/requirements.txt @@ -1,4 +1,4 @@ -molecule-docker +molecule[docker] ansible-lint yamllint pydocker \ No newline at end of file diff --git a/molecule/test.sh b/molecule/test.sh new file mode 100755 index 0000000..7f8aff1 --- /dev/null +++ b/molecule/test.sh @@ -0,0 +1,18 @@ +RED=$(tput setaf 1) +GREEN=$(tput setaf 2) +BLUE=$(tput setaf 4) +RESET=$(tput sgr0) + +# amazonlinux:2 requires !python3 so we aren't really testing it +IMAGES=${1} +for image in ${IMAGES:=ubuntu:jammy ubuntu:noble amazonlinux:2023 rockylinux:8 rockylinux:9}; do + echo ">> ${BLUE}INFO${RESET} Testing ${image}" | tee -a molecule/test.log + tag="${image#*:}" + image="${image%%:*}" tag=${tag} pipenv run molecule test >> molecule/test.log 2>&1 + if [ "$?" -ne 0 ]; then + echo "== ${RED}FAILURE${RESET} did not complete successfully" | tee -a molecule/test.log + exit 1 + else + echo "== ${GREEN}SUCCESS${RESET}" + fi +done