This is a lab topology that is used to deploy the IIS Web server via Ansible.
Configure WinRM service.
# Download a script to configure WinRM service on Windows Server 2019
# This script sets up both HTTP and HTTPS listeners with a self-signed certificate # and enables the Basic authentication option on the service # (https://docs.ansible.com/ansible/2.5/user_guide/windows_setup.html)
https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1 -OutFile ConfigureRemotingForAnsible.ps1
# Run the PS file.
powershell -ExecutionPolicy RemoteSigned .\ConfigureRemotingForAnsible.ps1
.\ConfigureRemotingForAnsible.ps1
Check WinRM service is running and WinRM port status is listening.
Add Windows Server 2019 IP address into /etc/ansible/hosts.
[Windows2019]
192.168.5.4
Create a new WIndows2019 file under the group_vars directory. Ansible connects to Windows Server 2019 via WinRM over TLS with the listening port is 5986. The file name should be Windows2019.
Create a sample index.html file to copy to the IIS server directory on WIndows server 2019.
<html>
<head>
<title>Tung Ansible</title>
</head>
<body>
<h1 style="background-color:DodgerBlue;"> Use Ansible to install and configure IIS on WIndows 2019</h1>
<h3 style="color:Tomato;"> Welcome to Tung's Ansbile Test Page</h3>
<img src="http://imagefromtheinternet.jpg">
</body>
</html>
Run ansible to check to access Windows server 2019 machine.