# Getting error when trying to install IIS on Windows server.

**URL:** <https://forum.ansible.com/t/getting-error-when-trying-to-install-iis-on-windows-server/28772>\
**Category:** Ansible Project\
**Tags:** azure, windows\
**Created:** [October 12, 2018, 2:15am UTC](https://forum.ansible.com/t/getting-error-when-trying-to-install-iis-on-windows-server/28772 "2018-10-12T02:15:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ameya\_Agashe](https://avatars.discourse-cdn.com/v4/letter/a/54ee81/32.png) [@Ameya\_Agashe](https://forum.ansible.com/u/Ameya_Agashe)\
**Post date:** [October 12, 2018, 2:15am UTC](https://forum.ansible.com/t/getting-error-when-trying-to-install-iis-on-windows-server/28772/1 "2018-10-12T02:15:29Z")

</div>

Hi All,

I need your assistance to resolve this issue.

Error details when I run in -vvv option:

Using module file /opt/ansible/local/lib/python2.7/site-packages/ansible/modules/windows/win\_feature.py  
\<127.0.0.1\> PUT /home/ameya/.ansible/tmp/ansible-local-1269sNJo2N/tmpn6Pzqa TO /home/ameya/.ansible/tmp/ansible-tmp-1539310211.52-28225992127736/win\_feature.py  
\<127.0.0.1\> PUT /home/ameya/.ansible/tmp/ansible-local-1269sNJo2N/tmpE9GgM5 TO /home/ameya/.ansible/tmp/ansible-tmp-1539310211.52-28225992127736/args  
\<127.0.0.1\> EXEC /bin/sh -c ‘chmod u+x /home/ameya/.ansible/tmp/ansible-tmp-1539310211.52-28225992127736/ /home/ameya/.ansible/tmp/ansible-tmp-1539310211.52-28225992127736/win\_feature.py /home/ameya/.ansible/tmp/ansible-tmp-1539310211.52-28225992127736/args && sleep 0’  
\<127.0.0.1\> EXEC /bin/sh -c ‘/opt/ansible/bin/python2 /home/ameya/.ansible/tmp/ansible-tmp-1539310211.52-28225992127736/win\_feature.py /home/ameya/.ansible/tmp/ansible-tmp-1539310211.52-28225992127736/args && sleep 0’  
\<127.0.0.1\> EXEC /bin/sh -c ‘rm -f -r /home/ameya/.ansible/tmp/ansible-tmp-1539310211.52-28225992127736/ \> /dev/null 2\>&1 && sleep 0’  
fatal: [localhost]: FAILED! =\> {  
“changed”: false,  
“module\_stderr”: “”,  
“module\_stdout”: “”,  
“msg”: “MODULE FAILURE”,  
“rc”: 0  
}

My Ansible yaml file is below, note it’s not an idea yaml but I want to get a base build working

- name: Create Azure VM  
hosts: localhost  
connection: local  
tasks:

- name: Create resource group  
azure\_rm\_resourcegroup:  
name: rg\_networking  
location: australiasoutheast

- name: Create virtual network  
azure\_rm\_virtualnetwork:  
resource\_group: rg\_networking  
name: vmnet\_groups\_preprod  
address\_prefixes: “[10.97.0.0/16](http://10.97.0.0/16)”

- name: Add subnet  
azure\_rm\_subnet:  
resource\_group: rg\_networking  
name: subnet\_ax  
address\_prefix: “[10.97.3.0/24](http://10.97.3.0/24)”  
virtual\_network: vmnet\_groups\_preprod

- name: Create public IP address  
azure\_rm\_publicipaddress:  
resource\_group: rg\_networking  
allocation\_method: Static  
name: NXTPREPWEB-1\_IP  
register: output\_ip\_address

- name: Dump public IP for VM which will be created  
debug:  
msg: “The public IP is {{ output\_ip\_address.state.ip\_address }}.”

- name: Create Network Security Group that allows RDP  
azure\_rm\_securitygroup:  
resource\_group: rg\_networking  
name: nsg\_subnet\_ax  
rules:

- name: RDP  
protocol: Tcp  
destination\_port\_range: 3389  
access: Allow  
priority: 1002  
direction: Inbound

- name: Create virtual network inteface card  
azure\_rm\_networkinterface:  
resource\_group: rg\_networking  
name: subnet\_ax\_iis\_nic-1  
virtual\_network: vmnet\_groups\_preprod  
subnet: subnet\_ax  
public\_ip\_name: NXTPREPWEB-1\_IP  
security\_group: nsg\_subnet\_ax

- name: Create VM  
azure\_rm\_virtualmachine:  
resource\_group: rg\_networking  
name: NXTPREPWEB-1  
vm\_size: Standard\_DS1\_v2  
admin\_username: axlocaladmin  
admin\_password: Hash#Dollar$135  
os\_type: Windows  
network\_interfaces: subnet\_ax\_iis\_nic-1  
image:  
offer: WindowsServer  
publisher: MicrosoftWindowsServer  
sku: ‘2016-Datacenter’  
version: latest

- name: Install IIS (Web-Server and Web-Common-Http)  
win\_feature:  
name:

- Web-Server

- Web-Common-Http  
state: present

- name: Install IIS Web-Server with sub features and management tools  
win\_feature:  
name: Web-Server  
state: present  
include\_sub\_features: True  
include\_management\_tools: True  
register: win\_feature

- name: reboot if installing Web-Server feature requires it  
win\_reboot:  
when: win\_feature.reboot\_required

Would appreciate any assistance offered.

Kind Regards,  
Ameya Agashe

---

<div class="post-metadata">

**Author:** ![Ameya\_Agashe](https://avatars.discourse-cdn.com/v4/letter/a/54ee81/32.png) [@Ameya\_Agashe](https://forum.ansible.com/u/Ameya_Agashe)\
**Post date:** [October 12, 2018, 4:13am UTC](https://forum.ansible.com/t/getting-error-when-trying-to-install-iis-on-windows-server/28772/2 "2018-10-12T04:13:21Z")

</div>

Ok, Got through that hurdle now next!

Please find below update file

- name: Create Azure VM  
hosts: localhost  
connection: local  
tasks:

- name: Create resource group  
azure\_rm\_resourcegroup:  
name: rg\_networking  
location: australiasoutheast

- name: Create virtual network  
azure\_rm\_virtualnetwork:  
resource\_group: rg\_networking  
name: vmnet\_groups\_preprod  
address\_prefixes: “10.97.0.0/16”

- name: Add subnet  
azure\_rm\_subnet:  
resource\_group: rg\_networking  
name: subnet\_ax  
address\_prefix: “10.97.3.0/24”  
virtual\_network: vmnet\_groups\_preprod

- name: Create public IP address  
azure\_rm\_publicipaddress:  
resource\_group: rg\_networking  
allocation\_method: Static  
name: NXTPREPWEB-1\_IP  
register: output\_ip\_address

- name: Dump public IP for VM which will be created  
debug:  
msg: “The public IP is {{ output\_ip\_address.state.ip\_address }}.”

- name: Create Network Security Group that allows RDP  
azure\_rm\_securitygroup:  
resource\_group: rg\_networking  
name: nsg\_subnet\_ax  
rules:

- name: RDP  
protocol: Tcp  
destination\_port\_range: 3389  
access: Allow  
priority: 1002  
direction: Inbound

- name: Create virtual network inteface card  
azure\_rm\_networkinterface:  
resource\_group: rg\_networking  
name: subnet\_ax\_iis\_nic-1  
virtual\_network: vmnet\_groups\_preprod  
subnet: subnet\_ax  
public\_ip\_name: NXTPREPWEB-1\_IP  
security\_group: nsg\_subnet\_ax

- name: Create VM  
azure\_rm\_virtualmachine:  
resource\_group: rg\_networking  
name: NXTPREPWEB-1  
vm\_size: Standard\_DS1\_v2  
admin\_username: axlocaladmin  
admin\_password: Hash#Dollar$135  
os\_type: Windows  
network\_interfaces: subnet\_ax\_iis\_nic-1  
image:  
offer: WindowsServer  
publisher: MicrosoftWindowsServer  
sku: ‘2016-Datacenter’  
version: latest

- name: install features on new Azure Windows Server  
hosts: windows  
gather\_facts: no  
tasks:

- name: wait for connection to be online  
wait\_for\_connection:

- name: Install IIS (Web-Server and Web-Common-Http)  
win\_feature:  
name:

- Web-Server

- Web-Common-Http  
state: present

- name: Install IIS Web-Server with sub features and management tools  
win\_feature:  
name: Web-Server  
state: present  
include\_sub\_features: True  
include\_management\_tools: True  
register: feature\_install

- name: reboot if installing Web-Server feature requires it  
win\_reboot:  
when: win\_feature.reboot\_required

Now, when I run through Azure cloud shell, it gives me error as below:

When I login to Azure cloud shell to execute it keeps in complaining that  
[WARNING]: Could not match supplied host pattern, ignoring: windows

PLAY [install features on new Azure Windows Server] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
skipping: no hosts matched

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
localhost : ok=9 changed=0 unreachable=0 failed=0

Unfortunately there is no directory like /etc/ansible/host so how to inject configuration on newly created Azure VM?

Kind Regards,  
Ameya Agashe

---

<div class="post-metadata">

**Author:** ![Wouter\_Hummelink](https://avatars.discourse-cdn.com/v4/letter/w/48db29/32.png) [@Wouter\_Hummelink](https://forum.ansible.com/u/Wouter_Hummelink)\
**Post date:** [October 12, 2018, 4:28am UTC](https://forum.ansible.com/t/getting-error-when-trying-to-install-iis-on-windows-server/28772/3 "2018-10-12T04:28:38Z")

</div>

Look at the add\_host module to add freshly created hosts to your inventory
