#!/bin/bash [[ -z $1 ]] && echo " usage: ${0##*/} [apply|start-at-task]" && exit 1 playbook=$1 opt=$2 [[ ! -f hosts ]] && echo cannot find hosts && exit 1 [[ ! -f credentials.bash ]] && echo cannot find credentials.bash && exit 1 source credentials.bash if [[ -z $opt ]]; then echo CHECK opt="--check" elif [[ $opt = apply ]]; then echo APPLY opt="" else echo START AT TASK $opt opt="--start-at-task $opt" fi (( forks = `grep ^proc /proc/cpuinfo | head -1 | cut -f2 -d:` + 1 )) # https://docs.ansible.com/ansible/latest/reference_appendices/config.html#display-skipped-hosts # default is true #ANSIBLE_DISPLAY_SKIPPED_HOSTS=true # do not show skipped hosts when deployed configs depend on distro's release name [[ $playbook = tasks-sshguard.yml ]] && export ANSIBLE_DISPLAY_SKIPPED_HOSTS=false [[ $playbook = tasks-nftables.yml ]] && export ANSIBLE_DISPLAY_SKIPPED_HOSTS=false time ansible-playbook $playbook -i hosts -T 3 \ --extra-vars "tsdb_host=$tsdb_host" \ --extra-vars "tsdb_port=$tsdb_port" \ --extra-vars "tsdb_http_user=$tsdb_http_user" \ --extra-vars "tsdb_http_passwd=$tsdb_http_passwd" \ --extra-vars "log_host=$log_host" \ --extra-vars "log_port=$log_port" \ --extra-vars "log_http_user=$log_http_user" \ --extra-vars "log_http_passwd=$log_http_passwd" \ --forks $forks \ $opt #-vvv \ cat <