Ansible Repo for windows support
- Create a windows 2012 R2 server and a linux server using a keypair using say AWS Cloud Formation.
- In ansible_windows_repo update the inventory/hosts_ssh with IP address and Administrator password of windows server.
- In the .kitchen.yml file
- Set the ssh_key to the aws keypair for linux server e.g. spec/test.pem
- Set the hostname to ip address of linux server e.g.'54.229.103.38'
- In the group_var/windows-server.xml
- set the ansible_ssh_pass to the Windows administrator password
- To configure Windows Server logon using say RDP and:
- check winrm is enable by running:
winrm quickconfig
- Run the powershell script ConfigureRemotingForAnsible.ps1 to configure the server for remote access from ansible.
- if you get error "running scripts is disabled on your system" then in powershell run
Set-ExecutionPolicy RemoteSigned
- Make sure the firewall is open for winrm requests by running
netsh advfirewall firewall add rule name="WinRM-HTTPS" dir=in localport=5986 protocol=TCP action=allow
- check winrm is enable by running:
- Typically the user is
vagrant
and passwordvagrant
. - use the test-kitchen file
.kitchen.yml.vagrant
. - Same issues apply for configuring the Windows Server.
To test accessing the windows server from the linux box that runs ansible (where xxxxxxxx is the Administrator password):
python
import winrm
winrmsession = winrm.Session('10.0.2.15',auth=('Administrator','xxxxxxxx'))
winrmsession
result = winrmsession.run_ps("(Get-WindowsFeature).Where{$PSItem.Installed}")
https://www.mail-archive.com/[email protected]/msg19494.html
https://4sysops.com/archives/powershell-remoting-over-https-with-a-self-signed-ssl-certificate/