correct behaviour of win_iis when using site_id if site not found (#56567)

* Fixed #47057

* Fix trailing whitespace

* Change for review
pull/57091/head
ShachafGoldstein 6 years ago committed by Jordan Borean
parent 94566ed79c
commit 4490c0ba51

@ -0,0 +1,2 @@
bugfixes:
- "win_iis_website - site_id not used if no sites exist already and creating a new site (https://github.com/ansible/ansible/issues/47057)"

@ -84,7 +84,13 @@ Try {
# This is a bug in the New-WebSite commandlet. Apparently there must be at least one site configured in IIS otherwise New-WebSite crashes. # 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 # 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 $sites_list = get-childitem -Path IIS:\sites
if ($null -eq $sites_list) { $site_parameters.ID = 1 } if ($null -eq $sites_list) {
if ($site_id) {
$site_parameters.ID = $site_id
} else {
$site_parameters.ID = 1
}
}
$site = New-Website @site_parameters -Force $site = New-Website @site_parameters -Force
$result.changed = $true $result.changed = $true

Loading…
Cancel
Save