From 0daa4a4cf91be023e69d67cb965606bb9d79a50f Mon Sep 17 00:00:00 2001 From: Maxim Vershinin Date: Tue, 18 Aug 2026 12:49:54 +0400 Subject: [PATCH] CHANGE: adds a lock file to the scripts --- scripts/run_maintain_playbook.sh | 8 ++++++++ scripts/update_modules.sh | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/scripts/run_maintain_playbook.sh b/scripts/run_maintain_playbook.sh index f2b8a80..c677ec7 100755 --- a/scripts/run_maintain_playbook.sh +++ b/scripts/run_maintain_playbook.sh @@ -1,3 +1,11 @@ #!/bin/bash + +LOCK_FILE=/tmp/vmn_ansible_lock_file.lock + +while [ -f "$LOCK_FILE" ] +do + sleep 1s +done + source .venv/bin/activate ansible-playbook playbooks/maintain.yaml --vault-pass-file ~/vault_password -i inventory/hosts.yaml --private-key ~/.ssh/ansible_key diff --git a/scripts/update_modules.sh b/scripts/update_modules.sh index 624d2e5..2e88220 100755 --- a/scripts/update_modules.sh +++ b/scripts/update_modules.sh @@ -1,5 +1,8 @@ #!/bin/bash +# Create a lock file to prevent other scripts from running with old modules +touch /tmp/vmn_ansible_lock_file.lock + source .venv/bin/activate # Install python packages @@ -10,3 +13,6 @@ ansible-galaxy collection install -r requirements.yml -p ./collections/ # Install roles ansible-galaxy role install -r requirements.yml -p ./roles/ + +# Installation is finished, remove the lock +rm /tmp/vmn_ansible_lock_file.lock