-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwinRemote.yml
112 lines (95 loc) · 4.63 KB
/
winRemote.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
---
- name: "WinRM"
hosts: all
connection: winrm
vars:
ansible_user: "{{ usrR }}"
# ansible_password: "{{ passR }}"
ansible_password: "AdminPass"
ansible_connection: winrm
ansible_winrm_server_cert_validation: ignore
# http_port: 80
# domain: example.com
# ansible_paramiko_user: "{{ usrR }}"
# ansible_paramiko_pass: "{{ passR }}"
# ansible_ssh_private_key_file: /path/to/private_key
# ansible_ssh_pass: passphrase_for_private_key
### --- ansible-playbook -i SRV_IP_ADDRESS, --extra-vars 'usrR=Administrator [email protected] rdp=0' winRemote.yml -vvv ---###
tasks:
# - name: Check RDP enable with powershell
# win_command: powershell.exe Get-WmiObject -Class Win32_TerminalServiceSetting -Namespace root\CIMV2\TerminalServices -Computer localhost -Authentication 6
# register: output
# - debug: msg={{output}}
### ----- Add in command rdp=0 or rdp=1 ----- OK! ########
- name: Access/Allow RDP(rdp=0 or 1)
win_command: powershell.exe (Get-WmiObject -Class Win32_TerminalServiceSetting -Namespace root\CIMV2\TerminalServices -Computer localhost -Authentication 6).SetAllowTSConnections({{ rdp }},{{ rdp }})
- fail: msg="rdp=0 or 1"
when: rdp is undefined
- name: Check RDP enable with powershell
win_command: powershell.exe Get-WmiObject -Class Win32_TerminalServiceSetting -Namespace root\CIMV2\TerminalServices -Computer localhost -Authentication 6
###-----------------------------------------------------------------------------------------------------------------------------------------------------------###
### ----- Copy files in public download directory ----- OK! ###
# - debug: msg=" OS is {{ansible_distribution}}"
# - name: Copy PSTools
# win_copy:
# src: ./WIN/PSTools.zip
# dest: C:\Users\Public\Downloads\
# - name: Copy winzip msi package
# win_copy:
# src: ./WIN/wzipse40.msi
# dest: C:\Users\Public\Downloads\
### ---- Install msi package --------------------OK! ###
# - name: Install winzip msi package
# win_package:
# path: C:\Users\Public\Downloads\wzipse40.msi
# product_id: '{CF2BEA3C-26EA-32F8-AA9B-331F7E34BAXX}'
# #arguments: /q /n
# state: present
### ----- Install Windows Updates ------------------ OK! ###
# - name: Sow message on Desktop "Automated upgrade"
# win_msg:
# display_seconds: 60
# msg: Automated upgrade about to start.
# - name: Install all security, critical, and rollup updates
# win_updates:
# category_names:
# - SecurityUpdates
# - CriticalUpdates
# - UpdateRollups
# - name: Test the PsExec connection to the local system (target node) with your user
# win_command: shutdown -f -r -t 00
### ----------------------------------------------------------------------------------------------------------------------------------------------- ###
# win_psexec:
# ##command: whoami.exe
# #command: ipconfig /all
# command: shutdown -f -r -t 00
#register: output
# win_command: msiexec.exe /i C:\Users\Public\Downloads\wzcline60-64.msi /qn
# - name: Run command that only runs if folder exists and runs from a specific folder
# win_command: C:\Windows\System32\msiexec.exe /i C:\Users\Public\Downloads\wzipse40.msi /qn
# args:
# chdir: C:\Users\Public\Downloads\
#creates: C:\backup\
###-----------------------------------------------###
# - name: PRINT OUT THE OUTPUT VARIABLE
# debug:
# var: output
# command: '-i C:\Users\Administrator\Documents\PSTools\pskill.exe -t firefox.exe'
##interactive: no
##system: yes
# - name: Windows product key My Variant
# win_psexec:
# command: '-i cscript c:\windows\system32\slmgr.vbs /ipk <enter your 25-digit product key here>'
####### Windows product key ###############
#### slmgr.vbs /ipk <enter your 25-digit product key here>
####Type in: cd c:\windows\system32 then press the Enter key.
####Type in: cscript c:\windows\system32\slmgr.vbs /ato then press the Enter key.
# Response example
# ok: [server1] => {
# "msg": [
# "ansible_distribution Microsoft Windows Server 2008 R2 Standard ",
# "major version 6",
# "version 6.1.7601.65536"
# ]
# # when: ansible_distribution == 'Windows'
# debug: msg="My release is {{ansible_distribution}}"