reodered and added functionality

This commit is contained in:
rene
2022-02-16 18:01:50 +01:00
parent 57cf89ded0
commit b94b707e76
11 changed files with 148 additions and 74 deletions

View File

@@ -0,0 +1,24 @@
#!/bin/bash
# Options
ANSIBLEUSER="ansible"
BRANCH="{{ branch | default('master') }}"
LOGFILE="/var/log/ansible.log"
REPO="https://gitlab.social.my-wan.de/rene/ansible-pull.git"
VAULT_KEY="</path/to/ansible_vault_key>"
PRECMD="sudo systemd-inhibit --who='ansible-pull' --why='provisioning'"
# check if ansible-pull is already running, and if not, run it
if pgrep -f ansible-pull; then
printf "\n$(date +"%Y-%m-%d %H:%M:%S") A running ansible-pull process was found.\nExiting.\n"\
| tee -a "${LOGFILE}"
exit 1
else
if [[ ! $1 == "" ]]; then
"${PRECMD}" sudo -iH -u "${ANSIBLEUSER}" ansible-pull --vault-password-file="${VAULT_KEY}" -U "${REPO}" -C "${BRANCH}" --tags $1 2>&1
else
"${PRECMD}" sudo -iH -u "${ANSIBLEUSER}" ansible-pull --vault-password-file="${VAULT_KEY}" -o -U "${REPO}" -C "${BRANCH}" 2>&1
fi
fi