Search⌘ K
AI Features

Configure a Windows IIS Web Server

Explore how to configure a Windows IIS web server using an Ansible playbook. Learn to install IIS features, manage files, use Chocolatey for package installation, and restart services with handlers to automate and maintain your Windows environment effectively.

We'll cover the following...

Let’s configure a Windows host to run an IIS(Internet Information Services) web server with an Ansible playbook. You’ll perform the following steps:

  1. Create a new file named configure_iis_web_server.yml.
  2. Add the hosts line targeting the all group.
YAML
---
- hosts: all
  1. Use vars_prompts to prompt for a username and password.
YAML
vars_prompt:
- name: username
prompt: "Enter local username"
private: no
- name: password
prompt: "Enter password
  1. Define the connection variables for a Windows host.
YAML
vars:
ansible_user: "{{ username }}"
ansible_password: "{{ password }}"
ansible_connection: winrm
ansible_winrm_transport: ntlm
ansible_winrm_server_cert_validation: ignore
  1. Add the tasks list.
YAML
tasks:
  1. Install the web-server feature and all subfeatures with the win_feature module.
YAML
- name: Install IIS
win_feature:
name: web-server
include_management_tools: yes
include_sub_features: yes
state: present

win_feature is an Ansible module used to install or uninstall roles or features for Windows servers. It requires the name parameter, which is passed as a web-server. web-server is the Windows feature’s name to ...