diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ea2f75f..52d2ef9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -25,4 +25,4 @@ jobs: - name: install ansible run: pip install ansible - name: run ansible-playbook check - run: cd ansible && ansible-playbook setup.yml --check + run: ./setup.sh --check diff --git a/ansible/requirements.yml b/ansible/requirements.yml new file mode 100644 index 0000000..72fe72d --- /dev/null +++ b/ansible/requirements.yml @@ -0,0 +1,2 @@ +collections: + - name: community.general diff --git a/setup.sh b/setup.sh index 27e5188..a3b1c7d 100755 --- a/setup.sh +++ b/setup.sh @@ -1,5 +1,8 @@ #!/usr/bin/env bash +# Exit immediately if a command exits with a non-zero status +set -e + if ! command -v ansible-playbook &> /dev/null; then echo "Command ansible-playbook could not be found!" echo @@ -9,4 +12,18 @@ if ! command -v ansible-playbook &> /dev/null; then exit 1 fi -cd ./ansible && ansible-playbook --ask-become-pass setup.yml +ANSIBLE_PLAYBOOK_ARGS=() + +if ("$1" == "--help" || "$1" == "-h"); then + echo "Usage: setup.sh [OPTIONS]" + echo + echo "Options:" + echo "--check Run the playbook in check mode (default: false)" + exit 0 +elif ("$1" == "--check"); then + CHECK_PLAYBOOK_ARGS+=("--check") +fi + +cd ./ansible +ansible-galaxy collection install -r requirements.yml --upgrade +ansible-playbook --ask-become-pass setup.yml ${ANSIBLE_PLAYBOOK_ARGS[@]}