diff options
author | binary <me@rgoncalves.se> | 2020-09-08 18:41:19 +0200 |
---|---|---|
committer | binary <me@rgoncalves.se> | 2020-09-08 18:41:19 +0200 |
commit | 67b3a99074566ed09f2f30fb035b7b529dca8aab (patch) | |
tree | 1d32c43c771ca109f46f34d241270c1588f237be | |
parent | d897257bf6401999751eb824499fc476cad8ad7f (diff) | |
download | infrastructure-67b3a99074566ed09f2f30fb035b7b529dca8aab.tar.gz |
standalone script for applying roles in specific order
-rwxr-xr-x | apply_roles | 37 |
1 files changed, 37 insertions, 0 deletions
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 |