From 0c5c75cae0735ec3fbc553fa4f03347e97870a7b Mon Sep 17 00:00:00 2001 From: shulkv01 Date: Sun, 9 Mar 2025 16:02:34 +0000 Subject: [PATCH] Add ansible_role.yml --- ansible_role.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 ansible_role.yml diff --git a/ansible_role.yml b/ansible_role.yml new file mode 100644 index 0000000..77f31b4 --- /dev/null +++ b/ansible_role.yml @@ -0,0 +1,29 @@ +--- +- name: Get file modification time + stat: + path: "{{ file_path }}" + register: file_stat + +- name: Calculate time since last modification + set_fact: + file_modified_recently: "{{ (ansible_date_time.epoch | int - file_stat.stat.mtime | int) < time_threshold }}" + +- name: Debug modification time + debug: + msg: "File was modified recently: {{ file_modified_recently }}" + +- name: Skip task if file was modified recently + debug: + msg: "Skipping task as file was modified recently" + when: file_modified_recently + +- name: Execute the task if file was not modified recently + command: echo "File was not modified recently, executing the task" + when: not file_modified_recently + + +defaults/main.yml +--- +file_path: "/path/to/your/file" +time_threshold: 600 # 10 minutes (600 seconds) +