This commit is contained in:
2026-07-24 14:42:50 -05:00
parent 31eac61575
commit 303608172f
3 changed files with 1 additions and 1 deletions
+43
View File
@@ -0,0 +1,43 @@
#!/bin/bash
# - Process command line
GIT_REPO_BRANCH="production"
while [ $# -gt 0 ]; do
case "$1" in
-h|--help)
echo "Usage: $0 [--branch <branch name>]"
exit 0
;;
--branch)
shift 1
if [ $# -eq 0 ] ; then echo "$0: ERROR - Branch not specified." ; exit 1 ; fi
GIT_REPO_BRANCH="$1"
shift 1
;;
esac
done
# - Include ansible virtual environment
. "${HOME}/.ansible-venv/bin/activate"
SCRIPT_NAME="$(basename "${0}")"
GIT_REPO_BASE="https://gitea.admin-a.hpetersenfamily.com/heath/ansible"
GIT_REPO="${GIT_REPO_BASE}.git"
LOG_DIR="/var/log/ansible-pull.sh"
LOG_FILE="${LOG_DIR}/ansible-pull.sh.log"
LOCK_FILE="/tmp/ansible-pull.sh.lock"
# - Redirect all further output to the log file
exec >>"${LOG_FILE}" 2>&1
# - Log that we've gotten this far
echo -n "$(basename "${0}"): $(date "+%Y-%m-%d %H:%M:%S")"
# - If we can't lock the lock file, don't proceed
exec 9>"${LOCK_FILE}"
if ! flock -n 9 ; then echo " - ERROR - Another copy of ${SCRIPT_NAME} is already running! Exiting..." ; exit 1 ; fi
# - Do our work
echo
ansible-pull --only-if-changed --url "${GIT_REPO}" --checkout "${GIT_REPO_BRANCH}" "${@}"
+35
View File
@@ -0,0 +1,35 @@
#!/usr/bin/env sh
if [ -z "${1:-}" ] ; then
echo "ERROR - ansible OS family unspecified." >&2
exit 1
fi
ANSIBLE_OS_FAMILY="${1}"
shift
useradd_D() {
case "${ANSIBLE_OS_FAMILY}" in
Debian)
/usr/sbin/useradd -D
;;
RedHat)
/usr/sbin/useradd -D
;;
*)
echo "ERROR - Unknown ansible OS FAMILY \"${ANSIBLE_OS_FAMILY}\"." >&2
exit 99
;;
esac
}
user_vars() {
useradd_D | sed 's/.*=/hpf_fact_\L&/'
}
#echo '{"hpf":'
#(user_vars; ) | jo
#echo '}'
user_vars