Files
windows-ansible/ansible/roles/win_fileserver/tasks/scheduled_tasks.yml
T

72 lines
2.4 KiB
YAML

---
- name: add user rights to file-transfer user
tags: transfer_user_rights
ansible.windows.win_user_right:
name: SeBatchLogonRight
users:
- "{{ win_project }}\\{{ filetransfer_user }}"
action: add
- name: Copy scripts to fileserver
tags: copy_scheduled_tasks
block:
- name: Copy transfer scripts to fileserver
win_copy:
src: "{{ item }}"
dest: "{{ script_folder }}"
force: true
loop:
- "{{ import_script }}"
- "{{ export_script }}"
when: inventory_hostname in groups['meta-name_fs01']
- 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: s4u
path: "{{ scheduled_task_path }}"
actions:
- path: "{{ powershell_path }}"
arguments: "-NonInteractive -File {{ script_folder }}\\{{ export_script }}"
triggers:
- type: daily
start_boundary: "{{ task_start_time.stdout }}"
repetition:
interval: PT5M
multiple_instances: 1
run_level: highest
start_when_available: true
- name: Create import scheduled task
win_scheduled_task:
name: Import
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: s4u
path: "{{ scheduled_task_path }}"
actions:
- path: "{{ powershell_path }}"
arguments: "-NonInteractive -File {{ script_folder }}\\{{ import_script }}"
triggers:
- type: daily
start_boundary: "{{ task_start_time.stdout }}"
repetition:
interval: PT5M
multiple_instances: 1
run_level: highest
start_when_available: true
when: inventory_hostname in groups['meta-name_fs01']