From bf4e24c40dfe21307d6b8bf478916b8d3d8ef71e Mon Sep 17 00:00:00 2001 From: abrown38 Date: Fri, 23 Aug 2024 14:29:20 +0100 Subject: [PATCH] Fixed scheduled task creation --- .../win_fileserver/tasks/scheduled_tasks.yml | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/ansible/roles/win_fileserver/tasks/scheduled_tasks.yml b/ansible/roles/win_fileserver/tasks/scheduled_tasks.yml index d711a65..0d32059 100644 --- a/ansible/roles/win_fileserver/tasks/scheduled_tasks.yml +++ b/ansible/roles/win_fileserver/tasks/scheduled_tasks.yml @@ -15,19 +15,27 @@ - name: Create Scheduled Tasks tags: create_scheduled_tasks block: + - name: Get date +5 minutes for task start time + vars: + ansible_connection: local + shell: /usr/bin/date --date="+5 minutes" "+%Y-%m-%dT%T" + delegate_to: localhost + register: task_start_time + - name: Create export scheduled task community.windows.win_scheduled_task: name: Export description: Move files from Windows projects on S:\ to the folders on T:\ for Transfer username: "{{ win_project }}\\{{ filetransfer_user }}" password: "{{ transfer_user_password }}" - logon_type: password + logon_type: s4u path: "{{ scheduled_task_path }}" actions: - path: "{{ powershell_path }}" - arguments: "{{ script_folder }}\\{{ export_script }}" + arguments: "-NonInteractive -File {{ script_folder }}\\{{ export_script }}" triggers: - - type: registration + - type: daily + start_boundary: "{{ task_start_time.stdout }}" repetition: interval: PT5M @@ -37,13 +45,14 @@ description: Move files from Windows projects on T:\ to the folders on S:\ for Transfer username: "{{ win_project }}\\{{ filetransfer_user }}" password: "{{ transfer_user_password }}" - logon_type: password + logon_type: s4u path: "{{ scheduled_task_path }}" actions: - path: "{{ powershell_path }}" - arguments: "{{ script_folder }}\\{{ import_script }}" + arguments: "-NonInteractive -File {{ script_folder }}\\{{ import_script }}" triggers: - - type: registration + - type: daily + start_boundary: "{{ task_start_time.stdout }}" repetition: interval: PT5M when: inventory_hostname in groups['meta-name_fs01'] \ No newline at end of file