From 4fc4030c5832408611fe77e863acd51af942c47a Mon Sep 17 00:00:00 2001 From: Nicolas Landais Date: Thu, 8 Oct 2015 12:00:12 -0400 Subject: [PATCH] Adding fix to get around bug found with the New-Webstire command when running playbook on a vanilla machine. --- lib/ansible/modules/extras/windows/win_iis_website.ps1 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/ansible/modules/extras/windows/win_iis_website.ps1 b/lib/ansible/modules/extras/windows/win_iis_website.ps1 index 26a8df12730..4a9ccbba21f 100644 --- a/lib/ansible/modules/extras/windows/win_iis_website.ps1 +++ b/lib/ansible/modules/extras/windows/win_iis_website.ps1 @@ -102,6 +102,12 @@ Try { If ($bind_hostname) { $site_parameters.HostHeader = $bind_hostname } + + # Fix for error "New-Item : Index was outside the bounds of the array." + # This is a bug in the New-WebSite commandlet. Apparently there must be at least one site configured in IIS otherwise New-WebSite crashes. + # For more details, see http://stackoverflow.com/questions/3573889/ps-c-new-website-blah-throws-index-was-outside-the-bounds-of-the-array + $sites_list = get-childitem -Path IIS:\sites + if ($sites_list -eq $null) { $site_parameters.ID = 1 } $site = New-Website @site_parameters -Force $result.changed = $true