# The community.windows.win\_iis\_webapplication module shows as changed every time

**URL:** <https://forum.ansible.com/t/the-community-windows-win-iis-webapplication-module-shows-as-changed-every-time/4008>\
**Category:** Get Help\
**Tags:** windows, playbook, awx, collections\
**Created:** [February 22, 2024, 10:07pm UTC](https://forum.ansible.com/t/the-community-windows-win-iis-webapplication-module-shows-as-changed-every-time/4008 "2024-02-22T22:07:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![tompurl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/tompurl/32/2031_2.png) [@tompurl](https://forum.ansible.com/u/tompurl)\
**Post date:** [February 22, 2024, 10:07pm UTC](https://forum.ansible.com/t/the-community-windows-win-iis-webapplication-module-shows-as-changed-every-time/4008/1 "2024-02-22T22:07:56Z")

</div>

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

Here is my play:

```yaml
- name: "Create the web apps"
  community.windows.win_iis_webapplication:
    name: '{{ item.virtual_path }}'
    site: '{{ my_site_web_site.name }}'
    state: present
    physical_path: '{{ item.folder_path }}'
    application_pool: '{{ my_site_app_pool.name }}'
  loop: '{{ my_site_web_apps }}'
  notify: 'Restart web site: {{ my_site_web_site.name }}'

```

Here’s what my vars look like:

```yaml
---

debug: false
my_site_app_pool:
  name: My-Default
  auto_start: false
my_site_web_site:
  name: '{{ my_site_app_pool.name }}'
  path: 'D:\Inetpub\{{ my_site_app_pool.name }}'
  url: my-default.example.com
my_site_web_apps:
  - 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:

```json
{
    "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:

```auto
# 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.

What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![kurokobo](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kurokobo/32/182_2.png) [@kurokobo](https://forum.ansible.com/u/kurokobo)\
**Post date:** [February 23, 2024, 5:54am UTC](https://forum.ansible.com/t/the-community-windows-win-iis-webapplication-module-shows-as-changed-every-time/4008/2 "2024-02-23T05:54:59Z")

</div>

Hi, how about replacing `/` with `\`?

```yaml
my_site_web_apps:
  - 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'

```

---

<div class="post-metadata">

**Author:** ![tompurl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/tompurl/32/2031_2.png) [@tompurl](https://forum.ansible.com/u/tompurl)\
**Post date:** [February 23, 2024, 3:07pm UTC](https://forum.ansible.com/t/the-community-windows-win-iis-webapplication-module-shows-as-changed-every-time/4008/3 "2024-02-23T15:07:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kurokobo](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kurokobo/32/182_2.png) [@kurokobo](https://forum.ansible.com/u/kurokobo)\
**Post date:** [February 23, 2024, 3:21pm UTC](https://forum.ansible.com/t/the-community-windows-win-iis-webapplication-module-shows-as-changed-every-time/4008/4 "2024-02-23T15:21:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kurokobo](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kurokobo/32/182_2.png) [@kurokobo](https://forum.ansible.com/u/kurokobo)\
**Post date:** [February 23, 2024, 3:52pm UTC](https://forum.ansible.com/t/the-community-windows-win-iis-webapplication-module-shows-as-changed-every-time/4008/5 "2024-02-23T15:52:24Z")

</div>

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

![image](https://us1.discourse-cdn.com/ansible/original/2X/c/cff3412da23d67cca9b137fd28348c201e3dce5a.png)

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

![image](https://us1.discourse-cdn.com/ansible/original/2X/e/ecbb54fbc2a4ff9363b37795e79d5e43e6085040.png)

See this code block:

> <https://github.com/ansible-collections/community.windows/blob/588af79d4fb2255c0d1139fd1179c72efa20770b/plugins/modules/win_iis_webapplication.ps1#L81-L85>

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.

---

<div class="post-metadata">

**Author:** ![tompurl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/tompurl/32/2031_2.png) [@tompurl](https://forum.ansible.com/u/tompurl)\
**Post date:** [February 26, 2024, 5:08pm UTC](https://forum.ansible.com/t/the-community-windows-win-iis-webapplication-module-shows-as-changed-every-time/4008/6 "2024-02-26T17:08:09Z")

</div>

This is _very_ helpful @kurokobo , thank you!

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.

Thanks again for all of your help!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [March 27, 2024, 5:08pm UTC](https://forum.ansible.com/t/the-community-windows-win-iis-webapplication-module-shows-as-changed-every-time/4008/7 "2024-03-27T17:08:11Z")

</div>

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