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_webapppool improvements don't set attributes correctly #22805

Closed
virtuald opened this issue Mar 20, 2017 · 10 comments · Fixed by #22812
Closed

win_iis_webapppool improvements don't set attributes correctly #22805

virtuald opened this issue Mar 20, 2017 · 10 comments · Fixed by #22812
Labels
affects_2.3 This issue/PR affects Ansible v2.3 bug This issue/PR relates to a bug. module This issue/PR relates to a module. windows Windows community

Comments

@virtuald
Copy link
Contributor

ISSUE TYPE
  • Bug Report
COMPONENT NAME

win_iis_webapppool

ANSIBLE VERSION
$ ansible --version
ansible 2.3.0.0 (stable-2.3 b73a1be03a) last updated 2017/03/20 17:27:07 (GMT +000)
  config file =
  configured module search path = Default w/o overrides
  python version = 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]
CONFIGURATION
OS / ENVIRONMENT

Control host: Ubuntu 16.04
Target host: Windows Server 2012

SUMMARY

Attributes aren't set correctly, should have been fixed in #20680 but wasn't. Used test playbook from @deekayen as mentioned in the PR.

STEPS TO REPRODUCE
- hosts: all

  tasks:
    - name: "Install IIS."
      win_feature:
        name: "Web-Server"
        state: present
        restart: no
        include_sub_features: no
        include_management_tools: yes

    - name: "Create application pool with defaults."
      win_iis_webapppool:
        name: "GitHubPull20680_basic"
        state: started
      register: win_iis_webapppool_defaults

    - debug:
        var: win_iis_webapppool_defaults

    - name: "Create application pool with alternate settings."
      win_iis_webapppool:
        name: "GitHubPull20680_changes"
        state: started
        attributes: "autoStart:false|processModel.identityType:SpecificUser|processModel.userName:{{ user_iis_username }}|processModel.password:{{ user_iis_password }}|managedRuntimeVersion:v2.0|enable32BitAppOnWin64:true|managedPipelineMode:Classic"
      register: win_iis_webapppool_changes

    - debug:
        var: win_iis_webapppool_changes
ACTUAL RESULTS
TASK [Gathering Facts] ***********************************************************************************************
ok: [test]

TASK [Install IIS.] **************************************************************************************************
ok: [test]

TASK [Create application pool with defaults.] ************************************************************************
ok: [test]

TASK [debug] *********************************************************************************************************
ok: [test] => {
    "changed": false,
    "win_iis_webapppool_defaults": {
        "attributes": {},
        "changed": false,
        "info": {
            "attributes": {
                "CLRConfigFile": "",
                "applicationPoolSid": "S-1-5-82-2845532531-3417813578-2234105921-2210852024-1136530100",
                "autoStart": true,
                "enable32BitAppOnWin64": false,
                "enableConfigurationOverride": true,
                "managedPipelineMode": "Integrated",
                "managedRuntimeLoader": "webengine4.dll",
                "managedRuntimeVersion": "v4.0",
                "name": "GitHubPull20680_basic",
                "passAnonymousToken": true,
                "queueLength": 1000,
                "startMode": "OnDemand",
                "state": "Started"
            },
            "name": "GitHubPull20680_basic",
            "state": "Started"
        }
    }
}

TASK [Create application pool with alternate settings.] **************************************************************
ok: [test]

TASK [debug] *********************************************************************************************************
ok: [test] => {
    "changed": false,
    "win_iis_webapppool_changes": {
        "attributes": {},
        "changed": false,
        "info": {
            "attributes": {
                "CLRConfigFile": "",
                "applicationPoolSid": "S-1-5-82-2090956821-3273997103-1055353093-2979566528-3870201199",
                "autoStart": true,
                "enable32BitAppOnWin64": false,
                "enableConfigurationOverride": true,
                "managedPipelineMode": "Integrated",
                "managedRuntimeLoader": "webengine4.dll",
                "managedRuntimeVersion": "v4.0",
                "name": "GitHubPull20680_changes",
                "passAnonymousToken": true,
                "queueLength": 1000,
                "startMode": "OnDemand",
                "state": "Started"
            },
            "name": "GitHubPull20680_changes",
            "state": "Started"
        }
    }
}

PLAY RECAP ***********************************************************************************************************
test                 : ok=6    changed=0    unreachable=0    failed=0
@ansibot ansibot added affects_2.3 This issue/PR affects Ansible v2.3 bug_report module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. windows Windows community labels Mar 20, 2017
@jhawkesworth
Copy link
Contributor

Unfortunately you can only set attributes of the webapppool itself using this module.
It returns all the attributes that can be set in the response, it cannot set attributes in other parts of the IIS configuration.

If you need to set processModel attributes, I don't think there is a module for that (although pull requests always welcomed). You can, however, set processModel settings as described here: https://groups.google.com/forum/#!topic/ansible-project/L_FNHoh0nMM

@virtuald
Copy link
Contributor Author

Yes, but you'll note that 'attributes' in the response is empty (info.attributes has something however).

Referring to this comment in the original PR, you can see that their output and my output different. It seems one should be able to at the very least set the 'normal' attributes (for example, enable32BitAppOnWin64), otherwise what's the point of this module?

@virtuald
Copy link
Contributor Author

@jhawkesworth It appears that the following line is failing:

If (Get-Member -InputObject $params -Name attributes) {

If I add a Fail-Json to that if statement, it does not fail. However, if I add an 'else' and stick a Fail-Json in there, then that does fail.

Additionally, if I add the $params to $result, I can see that the attributes passed in the playbook do show up in the module, it just doesn't seem to be parsing them for some reason?

ok: [test] => {
    "changed": false,
    "win_iis_webapppool_changes": {
        "attributes": {},
        "changed": false,
        "foo": "hm",
        "info": {
            "attributes": {
                "CLRConfigFile": "",
                "applicationPoolSid": "S-1-5-82-2090956821-3273997103-1055353093-2979566528-3870201199",
                "autoStart": true,
                "enable32BitAppOnWin64": false,
                "enableConfigurationOverride": true,
                "managedPipelineMode": "Integrated",
                "managedRuntimeLoader": "webengine4.dll",
                "managedRuntimeVersion": "v4.0",
                "name": "GitHubPull20680_changes",
                "passAnonymousToken": true,
                "queueLength": 1000,
                "startMode": "OnDemand",
                "state": "Started"
            },
            "name": "GitHubPull20680_changes",
            "state": "Started"
        },
        "params": {
            "attributes": "autoStart:false|managedRuntimeVersion:v2.0|enable32BitAppOnWin64:true|managedPipelineMode:Classic",
            "name": "GitHubPull20680_changes",
            "state": "started"
        }
    }
}

@virtuald
Copy link
Contributor Author

If I uncomment the If statement checking for $params.attributes, then it is able to set the settings such as autoStart/enable32BitAppOnWin64/etc.

What's wrong with the If statement? A look on Stack Overflow suggests that Get-Member isn't the correct way to check for the existence of a property... however, I changed it and that didn't work either. Is there a way to inspect the rewritten powershell script as it exists on the target host?

@virtuald
Copy link
Contributor Author

Found it. Did the module API change recently? Switching Get-Member to Get-AnsibleParam does the trick.

@jhawkesworth
Copy link
Contributor

re-opening following further info from @virtuald

@jhawkesworth jhawkesworth reopened this Mar 21, 2017
@dagwieers
Copy link
Contributor

I think it is unfortunate that an awkward syntax was chosen for attributes: and not simply a YAML dictionary. I think we should at least add that as a NOTE: or FIXME: comment in the code, if not fix this right away ;-)

@virtuald
Copy link
Contributor Author

@dagwieers yeah, it feels really weird to me as well. In theory it could be changed to take either, and deprecate string attributes? Or just use a new name instead of changing the attributes parameter.

@jhawkesworth
Copy link
Contributor

Yeah agree it was awkward but I'd suggest just getting it functioning 'as is' and leaving enhancing it for a separate PR which can be tackled during 2.4 development (lets try and get bug fix cherry picked to 2.3 though)

@ryansb ryansb removed the needs_triage Needs a first human triage before being processed. label Mar 21, 2017
virtuald added a commit to virtuald/ansible that referenced this issue Mar 21, 2017
@virtuald
Copy link
Contributor Author

virtuald commented Mar 21, 2017

If this doesn't get cherry picked to 2.3 then you might as well delete this module from 2.3, as it won't do much of anything useful without it. :)

abadger pushed a commit that referenced this issue Mar 23, 2017
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 7, 2018
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.3 This issue/PR affects Ansible v2.3 bug This issue/PR relates to a bug. module This issue/PR relates to a module. windows Windows community
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants