aboutsummaryrefslogtreecommitdiffstats
path: root/apply_roles
diff options
context:
space:
mode:
authorbinary <me@rgoncalves.se>2020-09-08 18:41:19 +0200
committerbinary <me@rgoncalves.se>2020-09-08 18:41:19 +0200
commit67b3a99074566ed09f2f30fb035b7b529dca8aab (patch)
tree1d32c43c771ca109f46f34d241270c1588f237be /apply_roles
parentd897257bf6401999751eb824499fc476cad8ad7f (diff)
downloadinfrastructure-67b3a99074566ed09f2f30fb035b7b529dca8aab.tar.gz
standalone script for applying roles in specific order
Diffstat (limited to 'apply_roles')
-rwxr-xr-xapply_roles37
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
remember that computers suck.