diff --git a/changelogs/fragments/setup-json.yml b/changelogs/fragments/setup-json.yml new file mode 100644 index 00000000..4e8c13ef --- /dev/null +++ b/changelogs/fragments/setup-json.yml @@ -0,0 +1,2 @@ +minor_changes: + - setup - Remove dependency on shared function loaded by Ansible diff --git a/galaxy.yml b/galaxy.yml index e96d58b6..faef893c 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -1,6 +1,6 @@ namespace: ansible name: windows -version: 2.7.0 +version: 2.8.0 readme: README.md authors: - Jordan Borean @jborean93 diff --git a/plugins/modules/setup.ps1 b/plugins/modules/setup.ps1 index e7f751d9..8a0fbc12 100644 --- a/plugins/modules/setup.ps1 +++ b/plugins/modules/setup.ps1 @@ -25,20 +25,29 @@ $spec = @{ # This module can be called by the gather_facts action plugin in ansible-base. While it shouldn't add any new options # we need to make sure the module doesn't break if it does. To do this we need to add any options in the input args if ($args.Length -gt 0) { - $params = Get-Content -LiteralPath $args[0] | ConvertFrom-AnsibleJson + $params = Get-Content $args[0] | ConvertFrom-Json + if ($params) { + foreach ($prop in $params.PSObject.Properties.Name) { + if ($prop.StartsWith('_') -or $spec.options.ContainsKey($prop)) { + continue + } + $spec.options.$prop = @{ type = 'raw' } + } + } } else { $params = $complex_args -} -if ($params) { - foreach ($param in $params.GetEnumerator()) { - if ($param.Key.StartsWith('_') -or $spec.options.ContainsKey($param.Key)) { - continue + if ($params) { + foreach ($param in $params.GetEnumerator()) { + if ($param.Key.StartsWith('_') -or $spec.options.ContainsKey($param.Key)) { + continue + } + $spec.options."$($param.Key)" = @{ type = 'raw' } } - $spec.options."$($param.Key)" = @{ type = 'raw' } } } + $module = [Ansible.Basic.AnsibleModule]::Create($args, $spec) $measureSubset = $module.Params._measure_subset