ansible-collections / community.windows

Windows community collection for Ansible
https://galaxy.ansible.com/community/windows
GNU General Public License v3.0
205 stars 160 forks source link

win_iis_webapplication is not idempotent. Absent state does not work as expected. #559

Open felipe-rodriguez-parra opened 8 months ago

felipe-rodriguez-parra commented 8 months ago
SUMMARY

The state absent property does not work as expected.

ISSUE TYPE
COMPONENT NAME

community.windows.win_iis_webapplication

ANSIBLE VERSION
ansible [core 2.15.3]
  config file = /home/frodriguez/linceweb/ansible.cfg
  configured module search path = ['/home/frodriguez/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.11/site-packages/ansible
  ansible collection location = /home/frodriguez/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.11.5 (main, Oct 25 2023, 16:19:59) [GCC 8.5.0 20210514 (Red Hat 8.5.0-20)] (/usr/bin/python3.11)
  jinja version = 3.1.2
  libyaml = True
COLLECTION VERSION
# /usr/lib/python3.11/site-packages/ansible_collections
Collection        Version
----------------- -------
community.windows 1.13.0
CONFIGURATION
CONFIG_FILE() = /home/frodriguez/linceweb/ansible.cfg
DEFAULT_HOST_LIST(/home/frodriguez/linceweb/ansible.cfg) = ['/home/frodriguez/linceweb/inventory']
DEFAULT_LOAD_CALLBACK_PLUGINS(/home/frodriguez/linceweb/ansible.cfg) = True
DEFAULT_REMOTE_USER(/home/frodriguez/linceweb/ansible.cfg) = ansible
DEFAULT_STDOUT_CALLBACK(/home/frodriguez/linceweb/ansible.cfg) = yaml
HOST_KEY_CHECKING(/home/frodriguez/linceweb/ansible.cfg) = False
OS / ENVIRONMENT

Ansible master in CentOS and target node Windows Server 2022 (IIS).

STEPS TO REPRODUCE

iis_path_default: "C:\inetpub\WebCloud\"

# This tasks works properly... like expected
- name: Convert to web application Administracion
  community.windows.win_iis_webapplication:
    name: "Administration\\Administration.WebAPI.lcloud"
    application_pool: Administracion
    connect_as: pass_through
    physical_path: "{{ iis_path_default }}Administration\\Administration.WebAPI.lcloud"
    site: WebCloud
    state: present
  tags: debug

# but this doesn't remove the app in IIS
- name: Convert to web application Administracion
  community.windows.win_iis_webapplication:
    name: "Administration\\Administration.WebAPI.lcloud"
    application_pool: Administracion
    connect_as: pass_through
    physical_path: "{{ iis_path_default }}Administration\\Administration.WebAPI.lcloud"
    site: WebCloud
    state: absent
  tags: debug
ACTUAL RESULTS
TASK [iis : Convert to web application Administracion] ************************************************************************************************************************************************************************************************************************
task path: /home/frodriguez/linceweb/roles/iis/tasks/main.yaml:68
Using module file /usr/lib/python3.11/site-packages/ansible_collections/community/windows/plugins/modules/win_iis_webapplication.ps1
Pipelining is enabled.
<windows.came.com> ESTABLISH WINRM CONNECTION FOR USER: Parkare on PORT 5985 TO windows.came.com
EXEC (via pipeline wrapper)
changed: [windows.came.com] => changed=true
  application_pool: Administracion
  physical_path: C:\inetpub\WebCloud\Administration\Administration.WebAPI.lcloud

TASK [iis : Convert to web application Administracion] ************************************************************************************************************************************************************************************************************************
task path: /home/frodriguez/linceweb/roles/iis/tasks/main.yaml:78
Using module file /usr/lib/python3.11/site-packages/ansible_collections/community/windows/plugins/modules/win_iis_webapplication.ps1
Pipelining is enabled.
<windows.came.com> ESTABLISH WINRM CONNECTION FOR USER: Parkare on PORT 5985 TO windows.came.com
EXEC (via pipeline wrapper)
ok: [windows.came.com] => changed=false
  application_pool: Administracion
  physical_path: C:\inetpub\WebCloud\Administration\Administration.WebAPI.lcloud