From 65e4ceea3368f65889fcaf5ff56e53aed377c4d3 Mon Sep 17 00:00:00 2001 From: filip Date: Thu, 3 Apr 2025 09:37:44 +0200 Subject: [PATCH] extending provision.sh to support tags in plays --- scripts/_common.sh | 8 ++++++++ scripts/provision.sh | 1 + 2 files changed, 9 insertions(+) diff --git a/scripts/_common.sh b/scripts/_common.sh index 2eb8d4197..c95560935 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -24,6 +24,7 @@ LINT="no" ABSOLUTE_PLAYBOOK_PATH="no" PARALLEL_RUN="no" BOTO_PROFILE="" +TAGS="" # Ensure build workspace exists. if [ ! -d "$BUILD_WORKSPACE_BASE" ]; then mkdir "$BUILD_WORKSPACE_BASE" @@ -80,6 +81,10 @@ parse_options(){ "--list-tasks") LIST_TASKS="yes" ;; + "--tags") + shift + TAGS="$1" + ;; "--verbose") VERBOSE="yes" ;; @@ -196,6 +201,9 @@ ansible_play(){ if [ "$LIST_TASKS" = "yes" ]; then ANSIBLE_CMD="$ANSIBLE_CMD --list-tasks" fi + if [ -n "$TAGS" ]; then + ANSIBLE_CMD="$ANSIBLE_CMD --tags $TAGS" + fi if [ "$VERBOSE" = "yes" ]; then ANSIBLE_CMD="$ANSIBLE_CMD -vvvv" fi diff --git a/scripts/provision.sh b/scripts/provision.sh index fda465e05..76dd21a40 100755 --- a/scripts/provision.sh +++ b/scripts/provision.sh @@ -27,6 +27,7 @@ usage(){ echo '--boto-profile: Name of a profile to export as AWS_PROFILE before calling Ansible.' echo '--parallel: Run all playbooks in the --playbook directory in parallel (using ansible-parallel).' echo '--lint: Run ansible-lint against the playbooks instead of executing them.' + echo '--tags: Only tagged parts of the playbooks. Can be used in combo with --list tasks' } # Common processing.