Compare commits
2 Commits
6a5089eb01
...
3067b21276
| Author | SHA256 | Date | |
|---|---|---|---|
| 3067b21276 | |||
| 19f79cd518 |
+1
-1
@@ -126,7 +126,7 @@ system_useradd hpf-ans 800
|
|||||||
add_groups_to_user hpf-sudo-np hpf-ans
|
add_groups_to_user hpf-sudo-np hpf-ans
|
||||||
|
|
||||||
# Make sure .ansible-venv exists
|
# Make sure .ansible-venv exists
|
||||||
as_hpf_ans "if [ ! -d \"${HPF_ANS_ansible_venv}\" ] ; then python3 -m venv \"${HPF_ANS_ansible_venv}\" ; fi"
|
as_hpf_ans "if [ ! -d \"${HPF_ANS_ansible_venv}\" ] ; then virtualenv \"${HPF_ANS_ansible_venv}\" ; fi"
|
||||||
|
|
||||||
# Make sure pip is up to date
|
# Make sure pip is up to date
|
||||||
as_hpf_ans "pip install --upgrade pip"
|
as_hpf_ans "pip install --upgrade pip"
|
||||||
|
|||||||
@@ -1,14 +1,24 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
source ~/.ansible-venv/bin/activate
|
# - Fix branch to check out
|
||||||
|
|
||||||
|
. "${HOME}/.ansible-venv/bin/activate"
|
||||||
|
|
||||||
GIT_REPO_BASE="https://gitea.admin-a.hpetersenfamily.com/heath/ansible"
|
GIT_REPO_BASE="https://gitea.admin-a.hpetersenfamily.com/heath/ansible"
|
||||||
GIT_REPO="${GIT_REPO_BASE}.git"
|
GIT_REPO="${GIT_REPO_BASE}.git"
|
||||||
|
LOG_FILE="/var/log/ansible-pull.sh.log"
|
||||||
|
LOCK_FILE="/tmp/ansible-pull.sh.lock"
|
||||||
|
|
||||||
ANSIBLE_PULL_LOG="/var/log/ansible-pull.log"
|
# - Redirect all further output to the log file and create a lock file
|
||||||
|
exec >>"${LOG_FILE}" 2>&1 9>"${LOCK_FILE}"
|
||||||
|
|
||||||
echo | sudo tee -a "${ANSIBLE_PULL_LOG}"
|
# - Log that we've gotten this far
|
||||||
echo -n "$(basename "${0}"): " | sudo tee -a "${ANSIBLE_PULL_LOG}"
|
echo
|
||||||
date "+%Y-%m-%d %H:%M:%S" | sudo tee -a "${ANSIBLE_PULL_LOG}"
|
echo "$(basename "${0}"): $(date "+%Y-%m-%d %H:%M:%S")"
|
||||||
ansible-pull --only-if-changed --url "${GIT_REPO}" "${@}" 2>&1 | sudo tee -a "${ANSIBLE_PULL_LOG}"
|
echo "----------"
|
||||||
|
|
||||||
|
# - If we can't lock the lock file, don't proceed
|
||||||
|
if ! flock -n 9; then echo "ERROR - Another copy of ansible-pull.sh is already running! Exiting..." ; exit 1 ; fi
|
||||||
|
|
||||||
|
# - Do our work
|
||||||
|
ansible-pull --only-if-changed --url "${GIT_REPO}" --checkout main "${@}"
|
||||||
|
|||||||
Reference in New Issue
Block a user