win_ansible_role_rdp/tasks/main.yml
2022-12-30 01:32:02 +01:00

39 lines
1.3 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
- name: Create dir .ansible\status
ansible.windows.win_powershell:
script: '[System.IO.Directory]::CreateDirectory(".ansible\status")'
creates: '.ansible\status'
register: _a
- name: Create dir .ansible\status
ansible.windows.win_powershell:
script: 'attrib +h .ansible'
changed_when: _a.changed
- name: Touch a file (creates if not present, updates modification time if present)
ansible.windows.win_file:
path: .ansible\status\rdp.txt
state: touch
register: _a
# https://exchangepedia.com/2016/10/enable-remote-desktop-rdp-connections-for-admins-on-windows-server-2016.html
- name: Enable Remote Desktop connections
ansible.windows.win_powershell:
script: 'Set-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\ -Name “fDenyTSConnections” -Value 0'
changed_when: _a.changed
- name: Enable Network Level Authentication
ansible.windows.win_powershell:
script: 'Set-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp\ -Name “UserAuthentication” -Value 1'
changed_when: _a.changed
- name: Firewall rule to allow RDP on TCP port 3389
community.windows.win_firewall_rule:
name: Remote Desktop
localport: 3389
action: allow
direction: in
protocol: tcp
profiles: private
state: present
enabled: true