Hello! I am creating a bunch of IIS web sites under a web application and for some reason the community.windows.win_iis_webapplication module shows that it changes the web apps every time it is executed.
Finally, here’s what I get when I interrogate the web app using a one-liner:
# Output of this command:
# ansible --ask-vault-pass -i hosts.ini -m community.windows.win_iis_webapplication -a "name='App1' site='My-Default'" my-server
wi-web19d | SUCCESS => {
"application_pool": "My-Default",
"changed": false,
"connect_as": "pass_through",
"physical_path": "D:\\Inetpub\\My-Default/App1"
}
I’ve run this play a half-dozen times on the same server and it shows as changed every time. This makes little sense to me because everything looks idempotent to me.
By using / in your path, exact / is used in Physical Path for your application. This works, since Windows can handle / as same as \.
On the other hand, win_iis_webapplication module compares following two paths to determine if there is any diffs that should be modified:
(A) Current configured path for the application
(B) Specified path via physical_path
For now, (A) includes / as stated in screenshot above.
But (B) does NOT contain /, since it is compared with the FullName parameter of the object that is retrieved with Get-Item. The FullName parameter of the object that retrieved by Get-Item with the path contains /always uses \ as separator.
So by using / in the path in your playbook, the module always determines that the path is incorrect and should be modified, and returns changed. This is why I think the cause of your issue is using / in path.
Well, I’m surprised to say that I’m not having this issue any more I’m not sure why though. I made your suggested changes to the file paths, but even after repeated runs that didn’t seem to fix the problem.
I then changed the part of my module that creates an app pool. I changed the state property from “stopped” to “present”.
But that seems to be it, and now everything is working as expected.