The following are the terms and tools within the overall principles described above that successful DevOps engineers need to know
SETTING WINDOWS HOSTS
The Ansible Engine can do the following on Windows hosts:
• Start, stop and manage services
• Push and execute custom PowerShell script
• Use the Chocolatey Package Manager Management Pack
Setting up WinRM refer - WINRM Blog
In order for Ansible to communicate with a Windows host to use a Windows module, the Windows host must meet the following requirements:
Supported Windows versions of Ansible are usually matched with current and extended versions supported by Microsoft. Supported desktop operating systems include Windows 7, 8.1 and 10, and supported server operating systems include Windows Server 2008, 2008 R2, 2012, 2012 R2 and 2016.
• Ansible requires Windows hosts to install PowerShell 3.0 or higher and at least install .NET 4.0.
• You need to create and activate a WinRM listener.
#Upgrade permissions and .NET Framework
In order to use Ansible, PowerShell version 3.0 and .NET Framework 4.0 or higher require older operating systems such as Server 2008 and Windows 7. The basic image does not meet this requirement. You can upgrade these scripts using the Upgrade-PowerShell.ps1 script.
#Set-ExecutionPolicy -ExecutionPolicy No restriction-Force
#PS D:\>. \ Upgrade-PowerShell.ps1
When you are done, you will need to delete the automatic login and return the execution policy to the default value of Restricted.
To do this, use the following PowerShell command:
#Set-ExecutionPolicy -ExecutionPolicy Limited-Force
This script works by checking the programs that need to be installed (for example, .NET Framework 4.5.2) and the required version of PowerShell. If you need to reboot and configure the username and password parameters, the script will automatically restart and log in when you restart. The script will continue until no further action is required and the PowerShell version matches the target version. If the username and password parameters are not set, the script will manually restart the user and prompt them to log in if necessary. The next time the user logs in, the script continues from where it left off and continues the process until no further action is required.
Since the Ansible engine does not have a pywinrm dependency (it is required to use WinRM), make sure to install the pywinrm related library on the computer where Ansible is installed. The easiest way is to run pip install pywinrm on your terminal.
# yum –y update
# yum –y install python-pip
# pip install “pywinrm>=0.3.0”
# vi /etc/hosts
e.g 192.168.1.xx hostname
Setup inventory file:
To connect properly to a Windows host, you need to set ansible_connection = winrm in the host variable section of the manifest file so that Ansible Engine does not connect to the
Windows host via SSH.
In addition, the WinRM connection plugin communicates by default via https, but supports various modes such as http for message encryption. This certificate is a self-signed certificate and should not be verified. Therefore, the "Configure Ansible Remote Configuration" script we used earlier is not a valid CA from Python.
This is a sample host file, as you can see in one place (note that the details of your specific environment are different):
Go to your control node’s terminal and type
#ansible [host_group_name_in_inventory_file] -i hosts -m win_ping