Environmental requirements:
* Controller must be Linux
* Windows requires:
1.Framework 4.5
2.PowerShell 3.0
Raw materials:
Ansible Master (CentOS)
Anisble Slave (Windows SP1)
Steps:
[Linux]
Yum-y Install python-kerberos.x86_64 Python2-winrm.noarch
[Windows]
Download Framework 4.5
Http://download.microsoft.com/download/B/A/4/BA4A7E71-2906-4B2D-A0E1-80CF16844F5F/dotNetFx45_Full_x86_x64.exe
Download PowerShell 3.0
Https://download.microsoft.com/download/E/7/6/E76850B8-DA6E-4FF5-8CCE-A24FC513FD16/Windows6.1-KB2506143-x64.msu
Reboot once installation is complete
Download Remoting Script for Ansible
Https://github.com/ansible/ansible/blob/devel/examples/scripts/ConfigureRemotingForAnsible.ps1
Run a script with administrator status
Open PowerShell with Administrator status
WinRM QC
The following error will occur
650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M00/92/38/wKiom1j9c5TijbUlAANKhux-VqA613.png-wh_500x0-wm_ 3-wmp_4-s_1085019262.png "title=" anisble for Window1.png "alt=" Wkiom1j9c5tijbulaankhux-vqa613.png-wh_50 "/>
This is not really a mistake, just need to change the properties of the network: in the network and Sharing center of the public network, switch to a home network
650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M01/92/38/wKiom1j9c8fC079BAABQIdcvgSI525.png-wh_500x0-wm_ 3-wmp_4-s_3163994032.png "title=" Ansible_windows2.png "alt=" Wkiom1j9c8fc079baabqidcvgsi525.png-wh_50 "/>
Execute again
WinRM QC
This time it should be successful and will be shown in slices:
650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M01/92/38/wKiom1j9c9njErSCAAJ58Vf9IOY015.png-wh_500x0-wm_ 3-wmp_4-s_15575532.png "title=" Ansible_windows_3.png "alt=" Wkiom1j9c9njerscaaj58vf9ioy015.png-wh_50 "/>
Next you need to turn on properties related to Windows remote operations:
WinRM set Winrm/config/service ' @{allowunencrypted= "true"} '
WinRM set Winrm/config/service/auth ' @{basic= "true"} '
650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M01/92/38/wKiom1j9dILADIXPAABnCkM4Wgo947.png-wh_500x0-wm_ 3-wmp_4-s_2488826887.png "title=" Ansible_windows5.png "alt=" Wkiom1j9diladixpaabnckm4wgo947.png-wh_50 "/>
Above, you can see that port 5985 is up.
Netstat-ano | Findstr 5985
650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M00/92/38/wKiom1j9dKGjz45BAACi-PL4yxw979.png-wh_500x0-wm_ 3-wmp_4-s_539272568.png "title=" Ansible_window4.png "alt=" Wkiom1j9dkgjz45baaci-pl4yxw979.png-wh_50 "/>
Testing Windows hosts with Ansible
Cat/etc/ansible/hosts
[Windows]
10.0.50.100 ansible_ssh_user= "Administrator" ansible_ssh_pass= "123456" ansible_ssh_port=5986 ansible_connection= " WinRM
650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M01/92/37/wKioL1j9dZ-it7PxAAAwMxUrtAo981.png-wh_500x0-wm_ 3-wmp_4-s_2134761406.png "title=" Ss.png "alt=" Wkiol1j9dz-it7pxaaawmxurtao981.png-wh_50 "/>
This article is from the "Reiling ¿âë¹anti" blog, be sure to keep this source http://luweiv998.blog.51cto.com/4659209/1918756
Using the Ansible app under Windows