#!/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