-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path28_transfer_windows_to_windows_folder.yml
53 lines (42 loc) · 1.88 KB
/
28_transfer_windows_to_windows_folder.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
---
- name: "First Play - Socks Tunnel Check"
hosts: localhost
connection: local
gather_facts: true
roles:
- role: ansible-role-event-socks-tunnel
- name: "Second Play - This is the example of ansible to trnsfer file"
hosts: "{{ target_win_server }}"
gather_facts: true
vars:
target_win_server: "csc2cwn21112037.cloud.kp.org"
account_code: "{{ hostvars['localhost']['account_code'] }}"
trans_num: "{{ hostvars['localhost']['trans_num'] }}"
ansible_python_interpreter: "/usr/bin/python"
tasks:
- name: "Set-Fact User"
ansible.builtin.set_fact:
runuser: "{{ ansible_user }}"
runpass: "{{ ansible_password }}"
no_log: true
- name: "Block Loading To Send File From SMB Share To Windows Server - {{ target_win_server }}"
become: true
become_method: runas
become_user: "{{ runuser }}"
vars:
ansible_become_user: "{{ runuser }}"
ansible_become_pass: "{{ runpass }}"
block:
- name: "Check Directory"
ansible.builtin.win_shell: "Test-Path -Path 'C:\\VMware Tools\\Program File\\VMware\\VMware Tools\\Drivers\\pvscsi\\Win8'"
register: check_path_exist_status
- name: "Create Directory, If Not Exist"
ansible.builtin.win_shell: "New-Item -Path 'C:\\VMware Tools\\Program File\\VMware\\VMware Tools\\Drivers\\pvscsi\\Win8' -ItemType Directory"
register: directory_created_output
when: check_path_exist_status.stdout_lines[0] == "False"
- name: "Copy Folder From SMB Share - '10.15.214.205' => Windows Server - '{{ target_win_server }}'"
ansible.windows.win_copy:
src: "\\\\10.15.214.205\\E$\\Software\\PVSCSI Drivers\\pvscsi\\Win8\\"
dest: "C:\\VMware Tools\\Program File\\VMware\\VMware Tools\\Drivers\\pvscsi\\Win8"
remote_src: true
register: final_copy_output