diff --git a/changelogs/fragments/61227-win_iis_webapplication-apppool-change.yml b/changelogs/fragments/61227-win_iis_webapplication-apppool-change.yml new file mode 100644 index 00000000000..f500d99b788 --- /dev/null +++ b/changelogs/fragments/61227-win_iis_webapplication-apppool-change.yml @@ -0,0 +1,2 @@ +minor_changes: +- win_iis_webapplication - now uses the current application pool of the website instead of the DefaultAppPool if none was specified. diff --git a/lib/ansible/modules/windows/win_iis_webapplication.ps1 b/lib/ansible/modules/windows/win_iis_webapplication.ps1 index 5658ae73de8..587de19cb69 100644 --- a/lib/ansible/modules/windows/win_iis_webapplication.ps1 +++ b/lib/ansible/modules/windows/win_iis_webapplication.ps1 @@ -27,6 +27,12 @@ if ($null -eq (Get-Module "WebAdministration" -ErrorAction SilentlyContinue)) { # Application info $application = Get-WebApplication -Site $site -Name $name +$website = Get-Website -Name $site + +# Set ApplicationPool to current if not specified +if (!$application_pool) { + $application_pool = $website.applicationPool +} try { # Add application diff --git a/lib/ansible/modules/windows/win_iis_webapplication.py b/lib/ansible/modules/windows/win_iis_webapplication.py index 2ddc32b4ab5..3e293d989b2 100644 --- a/lib/ansible/modules/windows/win_iis_webapplication.py +++ b/lib/ansible/modules/windows/win_iis_webapplication.py @@ -40,6 +40,7 @@ options: application_pool: description: - The application pool in which the new site executes. + - If not specified, the application pool of the current website will be used. type: str seealso: - module: win_iis_virtualdirectory