From cfb4a8236f830765e43373d748f7fa582b7557f9 Mon Sep 17 00:00:00 2001 From: Jordan Borean Date: Tue, 26 Jun 2018 11:19:09 +1000 Subject: [PATCH] win_iis_webapppool: do not output some cmdlet outputs (#41884) (cherry picked from commit abfcc35e6f36af2394bb56ade73a0a431567240e) --- changelogs/fragments/win_iis_webapppool-output-fix.yml | 2 ++ lib/ansible/modules/windows/win_iis_webapppool.ps1 | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/win_iis_webapppool-output-fix.yml diff --git a/changelogs/fragments/win_iis_webapppool-output-fix.yml b/changelogs/fragments/win_iis_webapppool-output-fix.yml new file mode 100644 index 00000000000..db1d131417e --- /dev/null +++ b/changelogs/fragments/win_iis_webapppool-output-fix.yml @@ -0,0 +1,2 @@ +bugfixes: +- win_iis_webapppool - redirect some module output to null so Ansible can read the output JSON https://github.com/ansible/ansible/issues/40874 diff --git a/lib/ansible/modules/windows/win_iis_webapppool.ps1 b/lib/ansible/modules/windows/win_iis_webapppool.ps1 index cbbaedf5887..0de36db5f4a 100644 --- a/lib/ansible/modules/windows/win_iis_webapppool.ps1 +++ b/lib/ansible/modules/windows/win_iis_webapppool.ps1 @@ -189,7 +189,7 @@ if ($state -eq "absent") { if (-not $pool) { if (-not $check_mode) { try { - New-WebAppPool -Name $name + New-WebAppPool -Name $name > $null } catch { Fail-Json $result "Failed to create new Web App Pool $($name): $($_.Exception.Message)" } @@ -220,7 +220,7 @@ if ($state -eq "absent") { } foreach ($value in $new_value) { try { - New-ItemProperty -Path IIS:\AppPools\$name -Name $attribute_key -Value @{value=$value} -WhatIf:$check_mode + New-ItemProperty -Path IIS:\AppPools\$name -Name $attribute_key -Value @{value=$value} -WhatIf:$check_mode > $null } catch { Fail-Json -obj $result -message "Failed to add new attribute to Web App Pool $name. Attribute: $attribute_key, Value: $value, Exception: $($_.Exception.Message)" } @@ -241,7 +241,7 @@ if ($state -eq "absent") { if ($state -eq "started" -or $state -eq "restarted") { if (-not $check_mode) { try { - Start-WebAppPool -Name $name + Start-WebAppPool -Name $name > $null } catch { Fail-Json $result "Failed to start Web App Pool $($name): $($_.Exception.Message)" } @@ -252,7 +252,7 @@ if ($state -eq "absent") { if ($state -eq "stopped") { if (-not $check_mode) { try { - Stop-WebAppPool -Name $name + Stop-WebAppPool -Name $name > $null } catch { Fail-Json $result "Failed to stop Web App Pool $($name): $($_.Exception.Message)" } @@ -261,7 +261,7 @@ if ($state -eq "absent") { } elseif ($state -eq "restarted") { if (-not $check_mode) { try { - Restart-WebAppPool -Name $name + Restart-WebAppPool -Name $name > $null } catch { Fail-Json $result "Failed to restart Web App Pool $($name): $($_.Exception.Message)" }