The module shows as changed every time

Hello! I am creating a bunch of IIS web sites under a web application and for some reason the module shows that it changes the web apps every time it is executed.

Here is my play:

- name: "Create the web apps"
    name: '{{ item.virtual_path }}'
    site: '{{ }}'
    state: present
    physical_path: '{{ item.folder_path }}'
    application_pool: '{{ }}'
  loop: '{{ my_site_web_apps }}'
  notify: 'Restart web site: {{ }}'

Here’s what my vars look like:


debug: false
  name: My-Default
  auto_start: false
  name: '{{ }}'
  path: 'D:\Inetpub\{{ }}'
  - virtual_path: 'App1'
    folder_path: '{{ my_site_web_site.path }}/App1'
  - virtual_path: 'App2'
    folder_path: '{{ my_site_web_site.path }}/App2'

Here’s my output for one of the web apps that I see in AWX:

    "changed": true,
    "connect_as": "pass_through",
    "physical_path": "D:\\Inetpub\\My-Default/App1",
    "application_pool": "My-Default",
    "_ansible_no_log": false,
    "item": {
        "virtual_path": "App1",
        "folder_path": "D:\\Inetpub\\My-Default/App1"
    "ansible_loop_var": "item",
    "_ansible_item_label": {
        "virtual_path": "App1",
        "folder_path": "D:\\Inetpub\\My-Default/App1"

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 -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.

What am I doing wrong?

Hi, how about replacing / with \?

  - virtual_path: 'App1'
    # folder_path: '{{ my_site_web_site.path }}/App1'
    folder_path: '{{ my_site_web_site.path }}\App1'
  - virtual_path: 'App2'
    # folder_path: '{{ my_site_web_site.path }}/App2'
    folder_path: '{{ my_site_web_site.path }}\App2'

Thank you for the quick suggestion. I just tried your suggestion but unfortunately it didn’t make a difference.

Hmm, I know it will be changed the first time after replacing / with \, but will it continue to be changed after further re-runs?

Let me explain technical background:

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.

See this code block:

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.


This is very helpful @kurokobo , thank you!

Well, I’m surprised to say that I’m not having this issue any more :slight_smile: 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.

Thanks again for all of your help!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.