-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path28_transfer_linux_to_windows_file.yml
46 lines (39 loc) · 1.66 KB
/
28_transfer_linux_to_windows_file.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
---
- name: "Second Play - Socks Tunnel Check"
hosts: localhost
connection: local
gather_facts: true
roles:
- role: ansible-role-event-socks-tunnel
- name: "This is the example of ansible with python to read excel file data"
hosts: localhost
gather_facts: false
vars:
linux_jump: "csc2cxp21113105.cloud.kp.org"
windows_jump: "csc2cwp00008395.cloud.kp.org"
tasks:
- name: "Copying File From Linux Jump Host -> Localhost [Play On {{ linux_jump }}]"
ansible.builtin.fetch:
src: "/tmp/vcenter_topology_pzypsu9_vm.csv"
dest: "/tmp/"
flat: true
delegate_to: "{{ linux_jump }}" # Make Sure you add SSH cred to connect linux Server , it default use SSH cred otherwise
- name: "Read File From Localhost"
ansible.builtin.command:
cmd: "cat /tmp/vcenter_topology_pzypsu9_vm.csv"
register: vm_content_localhost
changed_when: vm_content_localhost.rc == 0
- name: "Copying File From Localhost -> windows Jump Host [Play On {{ windows_jump }}]"
ansible.windows.win_copy:
src: "/tmp/vcenter_topology_pzypsu9_vm.csv"
dest: "c:\\ANSIBLE_SMTP\\"
remote_src: false
delegate_to: "{{ windows_jump }}"
vars:
become_user: "{{ lookup('env', 'ANSIBLE_NET_USERNAME') }}"
become: true
ansible_python_interpreter: "/usr/bin/python"
ansible_user: "{{ lookup('env', 'ANSIBLE_NET_USERNAME') }}" # Make Sure you add NET cred to connect windows Server
ansible_password: "{{ lookup('env', 'ANSIBLE_NET_PASSWORD') }}"
account_code: "{{ hostvars['localhost']['account_code'] }}"
trans_num: "{{ hostvars['localhost']['trans_num'] }}"