Installing IIS on Windows Server 2008 R2 Standard SP1 x64

I have created a simple playbook to add IIS feature to a windows server.

`

  • name: Install IIS
    win_feature:
    name: “Web-WebServer, Web-Mgmt-Tools”
    state: present
    restart: yes
    include_sub_features: yes
    include_management_tools: yes

`

And this is the result:

`

[acabrera@cops-test ansible]$ ansible-playbook -vvvv -i hosts/rms ten201_rbo_web.yml

PLAY [Install Win feature ISS on RBO Web server] ******************************

GATHERING FACTS ***************************************************************
<rbapp31b22966.ms.rmsonecloud.net> ESTABLISH WINRM CONNECTION FOR USER: cpadm on PORT 5986 TO rbapp31b22966.ms.rmsonecloud.net
<rbapp31b22966.ms.rmsonecloud.net> WINRM CONNECT: transport=plaintext endpoint=https://rbapp31b22966.ms.rmsonecloud.net:5986/wsman
<rbapp31b22966.ms.rmsonecloud.net> REMOTE_MODULE setup
<rbapp31b22966.ms.rmsonecloud.net> EXEC (New-Item -Type Directory -Path $env:temp -Name “ansible-tmp-1437602865.92-148939687313381”).FullName | Write-Host -Separator ‘’;
<rbapp31b22966.ms.rmsonecloud.net> WINRM EXEC ‘PowerShell’ [‘-NoProfile’, ‘-NonInteractive’, ‘-EncodedCommand’, ‘KABOAGUAdwAtAEkAdABlAG0AIAAtAFQAeQBwAGUAIABEAGkAcgBlAGMAdABvAHIAeQAgAC0AUABhAHQAaAAgACQAZQBuAHYAOgB0AGUAbQBwACAALQBOAGEAbQBlACAAIgBhAG4AcwBpAGIAbABlAC0AdABtAHAALQAxADQAMwA3ADYAMAAyADgANgA1AC4AOQAyAC0AMQA0ADgAOQAzADkANgA4ADcAMwAxADMAMwA4ADEAIgApAC4ARgB1AGwAbABOAGEAbQBlACAAfAAgAFcAcgBpAHQAZQAtAEgAbwBzAHQAIAAtAFMAZQBwAGEAcgBhAHQAbwByACAAJwAnADsA’]
<rbapp31b22966.ms.rmsonecloud.net> WINRM RESULT <Response code 0, out “C:\Users\cpadm\AppDa”, err “”>
<rbapp31b22966.ms.rmsonecloud.net> PUT /tmp/tmpGesC_8 TO C:\Users\cpadm\AppData\Local\Temp\ansible-tmp-1437602865.92-148939687313381\setup
<rbapp31b22966.ms.rmsonecloud.net> WINRM PUT /tmp/tmpGesC_8 to C:\Users\cpadm\AppData\Local\Temp\ansible-tmp-1437602865.92-148939687313381\setup.ps1 (offset=0 size=2039)
<rbapp31b22966.ms.rmsonecloud.net> WINRM PUT /tmp/tmpGesC_8 to C:\Users\cpadm\AppData\Local\Temp\ansible-tmp-1437602865.92-148939687313381\setup.ps1 (offset=2039 size=2039)
<rbapp31b22966.ms.rmsonecloud.net> WINRM PUT /tmp/tmpGesC_8 to C:\Users\cpadm\AppData\Local\Temp\ansible-tmp-1437602865.92-148939687313381\setup.ps1 (offset=4078 size=2039)
<rbapp31b22966.ms.rmsonecloud.net> WINRM PUT /tmp/tmpGesC_8 to C:\Users\cpadm\AppData\Local\Temp\ansible-tmp-1437602865.92-148939687313381\setup.ps1 (offset=6117 size=2039)
<rbapp31b22966.ms.rmsonecloud.net> WINRM PUT /tmp/tmpGesC_8 to C:\Users\cpadm\AppData\Local\Temp\ansible-tmp-1437602865.92-148939687313381\setup.ps1 (offset=8156 size=1098)
<rbapp31b22966.ms.rmsonecloud.net> PUT /tmp/tmpy9Vivt TO C:\Users\cpadm\AppData\Local\Temp\ansible-tmp-1437602865.92-148939687313381\arguments
<rbapp31b22966.ms.rmsonecloud.net> WINRM PUT /tmp/tmpy9Vivt to C:\Users\cpadm\AppData\Local\Temp\ansible-tmp-1437602865.92-148939687313381\arguments (offset=0 size=2)
<rbapp31b22966.ms.rmsonecloud.net> EXEC PowerShell -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -File C:\Users\cpadm\AppData\Local\Temp\ansible-tmp-1437602865.92-148939687313381\setup.ps1 C:\Users\cpadm\AppData\Local\Temp\ansible-tmp-1437602865.92-148939687313381\arguments; Remove-Item "C:\Users\cpadm\AppData\Local\Temp\ansible-tmp-1437602865.92-148939687313381" -Force -Recurse;
<rbapp31b22966.ms.rmsonecloud.net> WINRM EXEC ‘PowerShell’ [‘-NoProfile’, ‘-NonInteractive’, ‘-EncodedCommand’, ‘UABvAHcAZQByAFMAaABlAGwAbAAgAC0ATgBvAFAAcgBvAGYAaQBsAGUAIAAtAE4AbwBuAEkAbgB0AGUAcgBhAGMAdABpAHYAZQAgAC0ARQB4AGUAYwB1AHQAaQBvAG4AUABvAGwAaQBjAHkAIABVAG4AcgBlAHMAdAByAGkAYwB0AGUAZAAgAC0ARgBpAGwAZQAgAEMAOgBcAFUAcwBlAHIAcwBcAGMAcABhAGQAbQBcAEEAcABwAEQAYQB0AGEAXABMAG8AYwBhAGwAXABUAGUAbQBwAFwAYQBuAHMAaQBiAGwAZQAtAHQAbQBwAC0AMQA0ADMANwA2ADAAMgA4ADYANQAuADkAMgAtADEANAA4ADkAMwA5ADYAOAA3ADMAMQAzADMAOAAxAFwAXABzAGUAdAB1AHAALgBwAHMAMQAgAEMAOgBcAFUAcwBlAHIAcwBcAGMAcABhAGQAbQBcAEEAcABwAEQAYQB0AGEAXABMAG8AYwBhAGwAXABUAGUAbQBwAFwAYQBuAHMAaQBiAGwAZQAtAHQAbQBwAC0AMQA0ADMANwA2ADAAMgA4ADYANQAuADkAMgAtADEANAA4ADkAMwA5ADYAOAA3ADMAMQAzADMAOAAxAFwAXABhAHIAZwB1AG0AZQBuAHQAcwA7ACAAUgBlAG0AbwB2AGUALQBJAHQAZQBtACAAIgBDADoAXABVAHMAZQByAHMAXABjAHAAYQBkAG0AXABBAHAAcABEAGEAdABhAFwATABvAGMAYQBsAFwAVABlAG0AcABcAGEAbgBzAGkAYgBsAGUALQB0AG0AcAAtADEANAAzADcANgAwADIAOAA2ADUALgA5ADIALQAxADQAOAA5ADMAOQA2ADgANwAzADEAMwAzADgAMQBcACIAIAAtAEYAbwByAGMAZQAgAC0AUgBlAGMAdQByAHMAZQA7AA==’]
<rbapp31b22966.ms.rmsonecloud.net> WINRM RESULT <Response code 0, out “{ “changed”: f”, err “”>
ok: [rbapp31b22966.ms.rmsonecloud.net] => {“ansible_facts”: {“ansible_distribution”: “Microsoft Windows NT 6.1.7601 Service Pack 1”, “ansible_distribution_version”: “6.1.7601.65536”, “ansible_fqdn”: “RBAPP31B22966.MS.RMSONECLOUD.NET”, “ansible_hostname”: “RBAPP31B22966”, “ansible_interfaces”: [{“default_gateway”: “10.64.24.1”, “dns_domain”: “ms.rmsonecloud.net”, “interface_index”: 12, “interface_name”: “vmxnet3 Ethernet Adapter #5”}], “ansible_ip_addresses”: [“10.64.24.14”, “fe80::f1c1:7db7:ea7b:20ff”], “ansible_os_family”: “Windows”, “ansible_powershell_version”: 3, “ansible_system”: “Win32NT”, “ansible_totalmem”: 17179869184, “ansible_winrm_certificate_expires”: “2025-07-13 22:30:42”}, “changed”: false}

TASK: [ten201 | Install IIS] **************************************************
<rbapp31b22966.ms.rmsonecloud.net> ESTABLISH WINRM CONNECTION FOR USER: cpadm on PORT 5986 TO rbapp31b22966.ms.rmsonecloud.net
<rbapp31b22966.ms.rmsonecloud.net> WINRM CONNECT: transport=plaintext endpoint=https://rbapp31b22966.ms.rmsonecloud.net:5986/wsman
<rbapp31b22966.ms.rmsonecloud.net> REMOTE_MODULE win_feature name=‘Web-WebServer, Web-Mgmt-Tools’ state=present
<rbapp31b22966.ms.rmsonecloud.net> EXEC (New-Item -Type Directory -Path $env:temp -Name “ansible-tmp-1437602912.73-281252093964288”).FullName | Write-Host -Separator ‘’;
<rbapp31b22966.ms.rmsonecloud.net> WINRM EXEC ‘PowerShell’ [‘-NoProfile’, ‘-NonInteractive’, ‘-EncodedCommand’, ‘KABOAGUAdwAtAEkAdABlAG0AIAAtAFQAeQBwAGUAIABEAGkAcgBlAGMAdABvAHIAeQAgAC0AUABhAHQAaAAgACQAZQBuAHYAOgB0AGUAbQBwACAALQBOAGEAbQBlACAAIgBhAG4AcwBpAGIAbABlAC0AdABtAHAALQAxADQAMwA3ADYAMAAyADkAMQAyAC4ANwAzAC0AMgA4ADEAMgA1ADIAMAA5ADMAOQA2ADQAMgA4ADgAIgApAC4ARgB1AGwAbABOAGEAbQBlACAAfAAgAFcAcgBpAHQAZQAtAEgAbwBzAHQAIAAtAFMAZQBwAGEAcgBhAHQAbwByACAAJwAnADsA’]
<rbapp31b22966.ms.rmsonecloud.net> WINRM RESULT <Response code 0, out “C:\Users\cpadm\AppDa”, err “”>
<rbapp31b22966.ms.rmsonecloud.net> PUT /tmp/tmpA5nJRf TO C:\Users\cpadm\AppData\Local\Temp\ansible-tmp-1437602912.73-281252093964288\win_feature
<rbapp31b22966.ms.rmsonecloud.net> WINRM PUT /tmp/tmpA5nJRf to C:\Users\cpadm\AppData\Local\Temp\ansible-tmp-1437602912.73-281252093964288\win_feature.ps1 (offset=0 size=2033)
<rbapp31b22966.ms.rmsonecloud.net> WINRM PUT /tmp/tmpA5nJRf to C:\Users\cpadm\AppData\Local\Temp\ansible-tmp-1437602912.73-281252093964288\win_feature.ps1 (offset=2033 size=2033)
<rbapp31b22966.ms.rmsonecloud.net> WINRM PUT /tmp/tmpA5nJRf to C:\Users\cpadm\AppData\Local\Temp\ansible-tmp-1437602912.73-281252093964288\win_feature.ps1 (offset=4066 size=2033)
<rbapp31b22966.ms.rmsonecloud.net> WINRM PUT /tmp/tmpA5nJRf to C:\Users\cpadm\AppData\Local\Temp\ansible-tmp-1437602912.73-281252093964288\win_feature.ps1 (offset=6099 size=2033)
<rbapp31b22966.ms.rmsonecloud.net> WINRM PUT /tmp/tmpA5nJRf to C:\Users\cpadm\AppData\Local\Temp\ansible-tmp-1437602912.73-281252093964288\win_feature.ps1 (offset=8132 size=2033)
<rbapp31b22966.ms.rmsonecloud.net> WINRM PUT /tmp/tmpA5nJRf to C:\Users\cpadm\AppData\Local\Temp\ansible-tmp-1437602912.73-281252093964288\win_feature.ps1 (offset=10165 size=39)
<rbapp31b22966.ms.rmsonecloud.net> PUT /tmp/tmp7DJHfn TO C:\Users\cpadm\AppData\Local\Temp\ansible-tmp-1437602912.73-281252093964288\arguments
<rbapp31b22966.ms.rmsonecloud.net> WINRM PUT /tmp/tmp7DJHfn to C:\Users\cpadm\AppData\Local\Temp\ansible-tmp-1437602912.73-281252093964288\arguments (offset=0 size=125)
<rbapp31b22966.ms.rmsonecloud.net> EXEC PowerShell -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -File C:\Users\cpadm\AppData\Local\Temp\ansible-tmp-1437602912.73-281252093964288\win_feature.ps1 C:\Users\cpadm\AppData\Local\Temp\ansible-tmp-1437602912.73-281252093964288\arguments; Remove-Item "C:\Users\cpadm\AppData\Local\Temp\ansible-tmp-1437602912.73-281252093964288" -Force -Recurse;
<rbapp31b22966.ms.rmsonecloud.net> WINRM EXEC ‘PowerShell’ [‘-NoProfile’, ‘-NonInteractive’, ‘-EncodedCommand’, ‘UABvAHcAZQByAFMAaABlAGwAbAAgAC0ATgBvAFAAcgBvAGYAaQBsAGUAIAAtAE4AbwBuAEkAbgB0AGUAcgBhAGMAdABpAHYAZQAgAC0ARQB4AGUAYwB1AHQAaQBvAG4AUABvAGwAaQBjAHkAIABVAG4AcgBlAHMAdAByAGkAYwB0AGUAZAAgAC0ARgBpAGwAZQAgAEMAOgBcAFUAcwBlAHIAcwBcAGMAcABhAGQAbQBcAEEAcABwAEQAYQB0AGEAXABMAG8AYwBhAGwAXABUAGUAbQBwAFwAYQBuAHMAaQBiAGwAZQAtAHQAbQBwAC0AMQA0ADMANwA2ADAAMgA5ADEAMgAuADcAMwAtADIAOAAxADIANQAyADAAOQAzADkANgA0ADIAOAA4AFwAXAB3AGkAbgBfAGYAZQBhAHQAdQByAGUALgBwAHMAMQAgAEMAOgBcAFUAcwBlAHIAcwBcAGMAcABhAGQAbQBcAEEAcABwAEQAYQB0AGEAXABMAG8AYwBhAGwAXABUAGUAbQBwAFwAYQBuAHMAaQBiAGwAZQAtAHQAbQBwAC0AMQA0ADMANwA2ADAAMgA5ADEAMgAuADcAMwAtADIAOAAxADIANQAyADAAOQAzADkANgA0ADIAOAA4AFwAXABhAHIAZwB1AG0AZQBuAHQAcwA7ACAAUgBlAG0AbwB2AGUALQBJAHQAZQBtACAAIgBDADoAXABVAHMAZQByAHMAXABjAHAAYQBkAG0AXABBAHAAcABEAGEAdABhAFwATABvAGMAYQBsAFwAVABlAG0AcABcAGEAbgBzAGkAYgBsAGUALQB0AG0AcAAtADEANAAzADcANgAwADIAOQAxADIALgA3ADMALQAyADgAMQAyADUAMgAwADkAMwA5ADYANAAyADgAOABcACIAIAAtAEYAbwByAGMAZQAgAC0AUgBlAGMAdQByAHMAZQA7AA==’]
<rbapp31b22966.ms.rmsonecloud.net> WINRM RESULT <Response code 0, out “{ “changed”: f”, err “”>
failed: [rbapp31b22966.ms.rmsonecloud.net] => {“changed”: false, “exitcode”: “InvalidArgs”, “failed”: true, “feature_result”: , “restart_needed”: false, “success”: false}
msg: Failed to add feature

FATAL: all hosts have already failed – aborting

PLAY RECAP ********************************************************************
to retry, use: --limit @/home/acabrera/ten201_rbo_web.retry

rbapp31b22966.ms.rmsonecloud.net : ok=1 changed=0 unreachable=0 failed=1

`

My ansible linux box is CEntOS 7.

Any ideas ?

Thanks in advance.

I have a couple of suggestions…

First, check your server 2008 is patched as per the instructions in the blue box here: http://docs.ansible.com/ansible/intro_windows.html#windows-system-prep

Check that your windows host actually has the features that you want to install available. Unfortunately some editions of windows don’t have the features included in the ISO image - I have experienced this with Volume Licensed editions in the past. If I recall correctly you can check this by running the following powershell as administrator on the windows machine:

import-module ServerManager; Get-WindowsFeature | Out-GridView

if the Install State listed for the feature you want to install is ‘Available’ then that’s not the issue.

Check eventvwr on the destination machine for messages / errors

I’d be tempted to remove the space between the two feature names in your playbook as per the example in the documentation page too.

Hope some of the above helps.

Also, what ansible version are you using and how was it installed?

I’m having the same problem.

TASK [iis : Install IIS] *******************************************************

/usr/local/lib/python2.7/dist-packages/winrm/transport.py:283: RuntimeError: kerberos.authGSSClientClean is deprecated.

krb_ticket.verify_response(response.headers[‘WWW-Authenticate’])

fatal: [qa1-ui.corp.wetdesign.com]: FAILED! => {“changed”: false, “exitcode”: “Failed”, “failed”: true, “feature_result”: , “msg”: “Failed to add feature”, “restart_needed”: false, “success”: false}

Control Machine = Ubuntu 14.04
Ansible Version = 2.0.0.2
Target Windows VM = Server 2012 R2
Playbook:

Ok, got it to work!

I’m not sure if it’s something to do with my Windows setup, but I had to comment out the below entries in the IIS playbook:

include_sub_features: yes

include_management_tools: yes

Maybe it has something to do with certain sub features not capable of installing? Anyways, give that a try. If it works for you as well, you will need to install each sub feature separately by adding them to the name list (comma-delimited).

Hey, are you able to fix the error?

TASK [iis : Install IIS] *******************************************************

/usr/local/lib/python2.7/dist-packages/winrm/transport.py:283: RuntimeError: kerberos.authGSSClientClean is deprecated.

krb_ticket.verify_response(response.headers[‘WWW-Authenticate’]

This is not affecting playbook run but distracting very much.