From 67b3a99074566ed09f2f30fb035b7b529dca8aab Mon Sep 17 00:00:00 2001 From: binary Date: Tue, 8 Sep 2020 18:41:19 +0200 Subject: standalone script for applying roles in specific order --- apply_roles | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 apply_roles (limited to 'apply_roles') diff --git a/apply_roles b/apply_roles new file mode 100755 index 0000000..1551cc7 --- /dev/null +++ b/apply_roles @@ -0,0 +1,37 @@ +#!/bin/bash +# +# Apply specific ansible tags/roles to selected machine + +# @usage +# Help fonction +function usage() { + echo "Usage: ${0} + -p : playbook file + -r : roles to be applied + -l : limit application to specific machines + -h : show this help, then exit + " +} + +while getopts "hp:r:l:" c; do + case ${c} in + p) + playbook="${OPTARG}" + ;; + r) + role="${OPTARG}" + ;; + l) + limit="${OPTARG}" + ;; + h) + usage; + exit 0; + esac +done + +echo ${role} + +for current_role in ${role[@]}; do + ansible-playbook "${playbook}" --tags "${current_role}" -l "${limit}" +done -- cgit v1.2.3