Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

win_iis_website: Setting physical path to '%SystemDrive%\inetpub\wwwroot' fails #589

Open
BradKnowles opened this issue Nov 5, 2024 · 1 comment

Comments

@BradKnowles
Copy link

SUMMARY
- name: Ensure Default Web Site Configuration
  community.windows.win_iis_website:
    name: Default Web Site
    application_pool: DefaultAppPool
    port: 80
    physical_path: '%SystemDrive%\inetpub\wwwroot'
    state: started

This task fails even though %SystemDrive%\inetpub\wwwroot does exist once the %SystemDrive% has been expanded. I have this task to ensure the Default Web Site settings haven't been tampered with. The tasks resets them to default values.

ISSUE TYPE
  • Bug Report
COMPONENT NAME
  • win_iis_website
ANSIBLE VERSION
ansible [core 2.16.11]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/ubuntu/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /home/ubuntu/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.10.12 (main, Sep 11 2024, 15:47:36) [GCC 11.4.0] (/usr/bin/python3)
  jinja version = 3.0.3
  libyaml = True
COLLECTION VERSION
# /usr/lib/python3/dist-packages/ansible_collections
Collection        Version
----------------- -------
community.windows 2.3.0
CONFIGURATION
CONFIG_FILE() = /home/ubuntu/edc/ansible.cfg
DEFAULT_GATHERING(/home/ubuntu/edc/ansible.cfg) = smart
DEFAULT_HOST_LIST(/home/ubuntu/edc/ansible.cfg) = ['/home/ubuntu/edc/inventories']
DEFAULT_LOG_PATH(/home/ubuntu/edc/ansible.cfg) = /home/ubuntu/edc/log.txt
DEFAULT_VAULT_PASSWORD_FILE(/home/ubuntu/edc/ansible.cfg) = /home/ubuntu/edc/vault-password
OS / ENVIRONMENT
  • Controller
    • Distributor ID: Ubuntu
      Description: Ubuntu 22.04.5 LTS
      Release: 22.04
      Codename: jammy
  • Target
    • Windows 2019
STEPS TO REPRODUCE
- name: Ensure Default Web Site Configuration
  community.windows.win_iis_website:
    name: Default Web Site
    application_pool: DefaultAppPool
    port: 80
    physical_path: '%SystemDrive%\inetpub\wwwroot'
    state: started

Use this task in a playbook targeting a Windows 2019 server with IIS installed.

EXPECTED RESULTS

The value of the Default Web Site physical path to be set to %SystemDrive%\inetpub\wwwroot

ACTUAL RESULTS
TASK [iis-config : Ensure Default Web Site Configuration] **************************************************************************************************
task path: /home/ubuntu/edc/roles/iis-config/tasks/main.yml:42
Using module file /usr/lib/python3/dist-packages/ansible_collections/community/windows/plugins/modules/win_iis_website.ps1
Pipelining is enabled.
<10.0.1.12> ESTABLISH WINRM CONNECTION FOR USER: ansible on PORT 5985 TO 10.0.1.12
EXEC (via pipeline wrapper)
fatal: [APP]: FAILED! => {
    "changed": false,
    "msg": "specified folder must already exist: physical_path",
    "site": {}
}
@BradKnowles
Copy link
Author

A potential fix would be to call [System.Environment]::ExpandEnvironmentVariables($physical_path) in the line validating the path

ElseIf (-not (Test-Path -LiteralPath $physical_path)) {

ElseIf (-not (Test-Path -LiteralPath [System.Environment]::ExpandEnvironmentVariables($physical_path))) {

That would expand the path, test it for existence, and still put the original specified path, with the %SystemDrive% intact.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant