Skip to content

win_dsc5.ps1 does not respect check mode in Ansible 2.3 stable #20

@Sholdaway

Description

@Sholdaway

Mentioned on Google Groups the other day: https://groups.google.com/forum/#!topic/ansible-devel/_qiLy2drebI

When calling win_dsc5 from a playbook or using ansible on the command line the --check parameter does not take effect. Basically, the tasks apply config rather than just reporting on what would have changed.

In the latest win_dsc5 code the $CheckFlag variable is being set by the following lines:

$params = Parse-Args $args -supports_check_mode $true
$CheckFlag = $params.psobject.Properties | where {$_.Name -eq "_ansible_check_mode"}

As the Parse-Args function in module_utils/powershell.ps1 is now outputting a hashtable rather than a custom PS Object the $params variable needs to be enumerated differently. I believe this is because the Parse-Args function has had an else condition added which is being hit every time.

    If ($arguments.Length -gt 0)
    {
        $params = Get-Content $arguments[0] | ConvertFrom-Json
    }
    Else {
        $params = $complex_args
    }

I'm still unsure of how the ansible executable passes args to the script(s) so I'm making slight presumptions!

I have a simple fix tested which brings this module into line with the "standard" Ansible way of setting the check flag in Windows modules (I think I used win_get_url and win_file as examples). Will submit a PR today and update this issue with some of my debugging methods.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions