Using Ansible applications under Windows
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
Restart once after the installation is complete
Download Remoting Script for Ansible
Https://github.com/ansible/ansible/blob/devel/examples/scripts/ConfigureRemotingForAnsible.ps1
Run the script as an administrator
* if encountered: PowerShell because script execution is prohibited on this system
Execute:
Set-ExecutionPolicy RemoteSigned
Open PowerShell as an administrator
Winrm qc
The following error occurs
In fact, this is not a mistake, it is only required to change the properties of the network: switch the public network to the home network in the network and sharing center.
Execute again
Winrm qc
This time it should be successful, and the following picture will be displayed:
Next, you need to enable the relevant properties of the windows remote operation:
Winrm set winrm/config/service'@ {AllowUnencrypted= "true"} 'winrm set winrm/config/service/auth' @ {Basic= "true"}'
Above, you can see that port 5985 is up.
Netstat-ano | findstr 5985
Test the windows host using 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"