Skip to content

Commit

Permalink
Update dependencies and makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
teddyphreak committed Oct 20, 2023
1 parent 80d588b commit ea8ece9
Show file tree
Hide file tree
Showing 13 changed files with 819 additions and 702 deletions.
5 changes: 5 additions & 0 deletions .ansible-lint-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This file contains ignores rule violations for ansible-lint
meta/main.yml schema[meta]
molecule/default/verify.yml no-changed-when
requirements.yml schema[requirements]
tasks/main.yml no-handler
6 changes: 0 additions & 6 deletions .ansible-lint.yml

This file was deleted.

17 changes: 6 additions & 11 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,11 @@ jobs:
with:
python-version: "3.x"

- name: Install poetry
run: pip3 install poetry
- name: Update ubuntu repositories
run: sudo apt-get update

- name: Install pips
run: poetry install
- name: Install make
run: sudo apt-get install -y make

- name: Lint code.
run: |
set -e
poetry run yamllint --version
poetry run yamllint .
poetry run ansible-lint --version
poetry run ansible-lint . -c .ansible-lint.yml
- name: Lint code
run: make lint
27 changes: 17 additions & 10 deletions .github/workflows/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,23 @@ jobs:
with:
python-version: "3.x"

- name: Install poetry
run: pip3 install poetry
- name: Update ubuntu repositories
run: sudo apt-get update

- name: Install pips
run: poetry install
- name: Install make
run: sudo apt-get install -y make

- name: Run Molecule tests.
run: poetry run molecule test
- name: Install dependencies
run: make install

- name: Debug test environment
run: make debug

- name: Run molecule tests.
run: make test
env:
PY_COLORS: "1"
ANSIBLE_FORCE_COLOR: "1"
MOLECULE_DOCKER_IMAGE: ${{ matrix.image }}
CF_ACCOUNT_TOKEN: ${{ secrets.CF_ACCOUNT_TOKEN }}
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
MOLECULE_DOCKER_IMAGE: ${{ matrix.image.name }}
MOLECULE_DOCKER_COMMAND: ${{ matrix.image.command }}
MOLECULE_SCENARIO: ${{ matrix.scenario.name }}
18 changes: 13 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,17 @@ jobs:
with:
python-version: '3.x'

- name: Install Ansible.
run: pip3 install ansible-base
- name: Update ubuntu repositories
run: sudo apt-get update

- name: Trigger a new import on Galaxy.
run: >-
ansible-galaxy role import --api-key ${{ secrets.GALAXY_API_KEY }} $(echo $GITHUB_REPOSITORY | cut -d/ -f1) $(echo $GITHUB_REPOSITORY | cut -d/ -f2)
- name: Install make
run: sudo apt-get install -y make

- name: Install dependencies
run: make install

- name: Trigger a new import on galaxy
run: make publish
env:
GALAXY_API_KEY: "${{ secrets.GALAXY_API_KEY }}"
GITHUB_REPOSITORY: "${{ github.repository }}"
5 changes: 5 additions & 0 deletions .talismanrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fileignoreconfig:
- filename: poetry.lock
ignore_detectors: [filecontent]
- filename: .github/workflows/release.yml
ignore_detectors: [filecontent]
54 changes: 52 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,52 @@
molecule:
molecule test
.PHONY: all ${MAKECMDGOALS}

MOLECULE_SCENARIO ?= default
MOLECULE_DOCKER_IMAGE ?= ubuntu2004
GALAXY_API_KEY ?=
GITHUB_REPOSITORY ?= $$(git config --get remote.origin.url | cut -d: -f 2 | cut -d. -f 1)
GITHUB_ORG = $$(echo ${GITHUB_REPOSITORY} | cut -d/ -f 1)
GITHUB_REPO = $$(echo ${GITHUB_REPOSITORY} | cut -d/ -f 2)
REQUIREMENTS = requirements.yml

all: install version lint test

install:
@type poetry >/dev/null || pip3 install poetry
@poetry install

lint: install
poetry run yamllint .
poetry run ansible-lint .
poetry run molecule syntax

roles:
[ -f ${REQUIREMENTS} ] && yq '.$@[] | .name' -r < ${REQUIREMENTS} \
| xargs -L1 poetry run ansible-galaxy role install --force || exit 0

collections:
[ -f ${REQUIREMENTS} ] && yq '.$@[]' -r < ${REQUIREMENTS} \
| xargs -L1 echo poetry run ansible-galaxy -vvv collection install --force || exit 0

requirements: roles collections

dependency create prepare converge idempotence side-effect verify destroy login reset:
MOLECULE_DOCKER_IMAGE=${MOLECULE_DOCKER_IMAGE} poetry run molecule $@ -s ${MOLECULE_SCENARIO}

ignore:
poetry run ansible-lint --generate-ignore

clean: destroy reset
@poetry env remove $$(which python) >/dev/null 2>&1 || exit 0

publish:
@echo publishing repository ${GITHUB_REPOSITORY}
@echo GITHUB_ORGANIZATION=${GITHUB_ORG}
@echo GITHUB_REPOSITORY=${GITHUB_REPO}
@poetry run ansible-galaxy role import \
--api-key ${GALAXY_API_KEY} ${GITHUB_ORG} ${GITHUB_REPO}

version:
@poetry run molecule --version

debug: version
@poetry export --dev --without-hashes
2 changes: 1 addition & 1 deletion molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dependency:
driver:
name: docker
platforms:
- name: instance
- name: Instance
image: "geerlingguy/docker-${MOLECULE_DOCKER_IMAGE:-ubuntu2204}-ansible:latest"
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
Expand Down
2 changes: 1 addition & 1 deletion molecule/default/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

tasks:

- name: update apt package cache
- name: Update apt package cache
apt:
update_cache: yes
when: (ansible_os_family | lower) == 'debian'
8 changes: 4 additions & 4 deletions molecule/default/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@

tasks:

- name: test certificate chain
- name: Test certificate chain
ansible.builtin.command: "openssl verify -CAfile {{ cacert }} -untrusted {{ intcert }} {{ crtfile }}"

- name: test certificate key
- name: Test certificate key
ansible.builtin.command: "openssl rsa -in {{ keyfile }}"

- name: test certificate chain symlinks
- name: Test certificate chain symlinks
ansible.builtin.command: "openssl verify -CAfile {{ calink }} -untrusted {{ intlink }} {{ crtlink }}"

- name: test certificate key symlinks
- name: Test certificate key symlinks
ansible.builtin.command: "openssl rsa -in {{ keylink }}"
Loading

0 comments on commit ea8ece9

Please sign in to comment.