Skip to content

Commit

Permalink
Few more Windows settings + Vagrant test script added
Browse files Browse the repository at this point in the history
  • Loading branch information
ruzickap committed Mar 16, 2018
1 parent e236e3f commit 3d4d245
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 7 deletions.
55 changes: 48 additions & 7 deletions tasks/Win32NT-common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@

- name: Enable Remote Desktop
win_regedit:
key: 'HKLM:\System\CurrentControlSet\Control\Terminal Server'
value: fDenyTSConnections
path: 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server'
name: fDenyTSConnections
data: 0
datatype: dword
type: dword

- name: Allow connections from computers running any version of Remote Desktop (less secure)
win_regedit:
key: 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp'
value: UserAuthentication
path: 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp'
name: UserAuthentication
data: 0
datatype: dword
type: dword

- name: Allow RDP traffic
win_shell: Enable-NetFirewallRule -DisplayGroup "Remote Desktop"
Expand All @@ -34,8 +34,49 @@
account_disabled: no
when: ansible_distribution | search("Microsoft Windows 10")

- name: Show file extensions in Explorer
win_regedit:
path: 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced'
name: HideFileExt
data: 0
type: dword

- name: Show hidden files
win_regedit:
path: 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced'
name: "{{ item }}"
data: 1
type: dword
with_items:
- Hidden
- SuperHidden
- ShowSuperHidden

- name: Enable QuickEdit mode
win_regedit:
path: 'HKCU:\Console'
name: QuickEdit
data: 1
type: dword
when: ansible_distribution | search("Microsoft Windows Server 2012")

- block:
- name: Zero Hibernation File
win_regedit:
path: 'HKLM:\SYSTEM\CurrentControlSet\Control\Power'
name: HibernateFileSizePercent
data: 0
type: dword

- name: Disable Hibernation Mode
win_regedit:
path: 'HKLM:\SYSTEM\CurrentControlSet\Control\Power'
name: HibernateEnabled
data: 0
type: dword
when: ansible_distribution | search("Microsoft Windows 10")

# Windows Updates is not working in ansible-2.4.0.0-1.fc27 and latest Ansible 2.4.2 is not working at all with Packer + WinRM
# That's the reason why updates are disabled for now...
#- name: Install windows updates
# win_updates:

33 changes: 33 additions & 0 deletions tests/vagrant_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash -eu

TEMP_PATH="/tmp/mytest/"
VAGRANT_BOXES="peru/windows-server-2016-standard-x64-eval peru/windows-10-enterprise-x64-eval peru/windows-server-2012-r2-standard-x64-eval"

IP_ADDRESSES=""
for VAGRANT_BOX in $VAGRANT_BOXES; do
BOX="${VAGRANT_BOX##*/}"
echo "*** $VAGRANT_BOX : $BOX"

test -d "$TEMP_PATH/$BOX" || mkdir -v -p "$TEMP_PATH/$BOX"
cd "$TEMP_PATH/$BOX"
test -f Vagrantfile || vagrant init $VAGRANT_BOX
VAGRANT_DEFAULT_PROVIDER=libvirt vagrant up
IP_ADDRESSES="`vagrant winrm-config | awk '/HostName/ { print $2 }'`,$IP_ADDRESSES"
cd -
done

ansible-playbook --extra-vars "ansible_user=vagrant ansible_password=vagrant ansible_port=5986 ansible_connection=winrm ansible_winrm_server_cert_validation=ignore" -i "$IP_ADDRESSES" ./test.yml
ansible-playbook --extra-vars "ansible_user=Administrator ansible_password=vagrant ansible_port=5986 ansible_connection=winrm ansible_winrm_server_cert_validation=ignore" -i "$IP_ADDRESSES" ./test.yml

echo "Press ENTER to Destroy all VMs"
read A

for VAGRANT_BOX in $VAGRANT_BOXES; do
BOX="${VAGRANT_BOX##*/}"
echo "*** Removing $VAGRANT_BOX : $BOX: $TEMP_PATH/$BOX"

cd "$TEMP_PATH/$BOX"
vagrant destroy -f
cd -
rm -rf "$TEMP_PATH/$BOX"
done

0 comments on commit 3d4d245

Please sign in to comment.