diff --git a/.gitignore b/.gitignore index 3efabe7..f56294b 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ playbooks/testing.yml *.idea **/__pycache__/ .venv/ +.ansible/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d13d03d --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +clean: + rm --recursive --force .ansible/ + +dev: + poetry install --remove-untracked + poetry run pre-commit install + poetry run ansible-galaxy collection install --requirements-file ./requirements.yaml --collections-path ./.ansible + ./dynamically-link-local-collections.bash diff --git a/dynamically-link-local-collections.bash b/dynamically-link-local-collections.bash new file mode 100755 index 0000000..c6d8ee0 --- /dev/null +++ b/dynamically-link-local-collections.bash @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +PWD=$(pwd) +ANSIBLE_NAMESPACE="skylab" +ANSIBLE_COLLECTION_DIR="$PWD/.ansible/ansible_collections" + +mkdir --parents "$ANSIBLE_COLLECTION_DIR/$ANSIBLE_NAMESPACE" + +for collection_path in "$PWD"/"$ANSIBLE_NAMESPACE"/*; do + collection=$(basename "$collection_path") + if [[ ! -L "$ANSIBLE_COLLECTION_DIR/$ANSIBLE_NAMESPACE/$collection" ]]; then + echo "Linking $ANSIBLE_NAMESPACE.$collection into $ANSIBLE_COLLECTION_DIR" + rm --recursive --force "${ANSIBLE_COLLECTION_DIR:?}/$ANSIBLE_NAMESPACE/$collection" + ln --symbolic "$PWD/$ANSIBLE_NAMESPACE/$collection" "$ANSIBLE_COLLECTION_DIR/$ANSIBLE_NAMESPACE/$collection" + fi +done + +echo "Done!"