enroll/tests.sh

41 lines
850 B
Bash
Raw Normal View History

2025-12-15 11:04:54 +11:00
#!/bin/bash
2025-12-15 11:29:19 +11:00
set -eo pipefail
# Pytests
2025-12-15 11:04:54 +11:00
poetry run pytest -vvvv --cov=enroll --cov-report=term-missing --disable-warnings
2025-12-15 11:29:19 +11:00
BUNDLE_DIR="/tmp/bundle"
ANSIBLE_DIR="/tmp/ansible"
rm -rf "${BUNDLE_DIR}" "${ANSIBLE_DIR}"
# Generate data
poetry run \
2025-12-16 20:48:08 +11:00
enroll single-shot \
2025-12-15 11:29:19 +11:00
--harvest "${BUNDLE_DIR}" \
--out "${ANSIBLE_DIR}"
# Analyse
poetry run \
enroll explain "${BUNDLE_DIR}"
poetry run \
enroll explain "${BUNDLE_DIR}" --format json | jq
2025-12-15 11:29:19 +11:00
# Install something, harvest again and diff the harvests
sudo apt-get -y install cowsay
poetry run \
enroll harvest --out "${BUNDLE_DIR}2"
poetry run \
enroll diff \
--old "${BUNDLE_DIR}" \
--new "${BUNDLE_DIR}2" \
--format json | jq
# Ansible test
builtin cd "${ANSIBLE_DIR}"
2025-12-15 11:29:19 +11:00
# Lint
ansible-lint "${ANSIBLE_DIR}"
2025-12-15 11:04:54 +11:00
2025-12-15 11:29:19 +11:00
# Run
2025-12-15 11:57:33 +11:00
ansible-playbook playbook.yml -i "localhost," -c local --check --diff