lock, add files which handle checking, creating, and then removing a temporary lock file.
This commit is contained in:
@@ -0,0 +1,16 @@
|
|||||||
|
---
|
||||||
|
# 20260929 - Hyperling
|
||||||
|
# Ensure an existing run is not active, otherwise bail.
|
||||||
|
|
||||||
|
- name: General | Tests | Existing Run | Facts
|
||||||
|
set_fact:
|
||||||
|
lock_file: "/tmp/ansible-playbook.lock"
|
||||||
|
|
||||||
|
- name: General | Tests | Existing Run | Check
|
||||||
|
stat:
|
||||||
|
path: "{{ lock_file }}"
|
||||||
|
register: lock_exists
|
||||||
|
|
||||||
|
- name: General | Tests | Existing Run | Exit
|
||||||
|
meta: end_play
|
||||||
|
when: lock_exists.stat.exists
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
# 20260929 - Hyperling
|
||||||
|
# Ensure an existing run is not active, otherwise bail.
|
||||||
|
|
||||||
|
- name: General | Tests | Existing Run | Lock | Create
|
||||||
|
shell: "date +'%Y-%m-%d %H:%M:%S' >> {{lock_file }}"
|
||||||
|
|
||||||
|
|
||||||
|
- name: General | Tests | Existing Run | Lock | Create
|
||||||
|
file:
|
||||||
|
name: "{{ lock_file }}"
|
||||||
|
mode: '0777'
|
||||||
|
|
||||||
|
- name: General | Tests | Existing Run | Lock | Create | Check
|
||||||
|
stat:
|
||||||
|
path: "{{ lock_file }}"
|
||||||
|
register: lock_exists
|
||||||
|
|
||||||
|
- name: General | Tests | Existing Run | Lock | Create | Fail
|
||||||
|
fail:
|
||||||
|
msg: "ERROR: Lock file does not exist."
|
||||||
|
when: not lock_exists.stat.exists
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
---
|
||||||
|
# 20260929 - Hyperling
|
||||||
|
# Ensure an existing run is not active, otherwise bail.
|
||||||
|
|
||||||
|
- name: General | Tests | Existing Run | Lock | Remove
|
||||||
|
file:
|
||||||
|
name: "{{ lock_file }}"
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: General | Tests | Existing Run | Lock | Remove | Check
|
||||||
|
stat:
|
||||||
|
path: "{{ lock_file }}"
|
||||||
|
register: lock_exists
|
||||||
|
|
||||||
|
- name: General | Tests | Existing Run | Lock | Remove | Fail
|
||||||
|
fail:
|
||||||
|
msg: "ERROR: Lock file still exists!"
|
||||||
|
when: lock_exists.stat.exists
|
||||||
Reference in New Issue
Block a user