-
Notifications
You must be signed in to change notification settings - Fork 169
Open
Description
SUMMARY
When setting state: latest
in a win_psmodule task the function Find-LatestPsModule
is called. This function returns a list of versions, if the module exists on multiple registered repositories and no repository was defined in the task. This results in a failure with an opaque error message (see ACTUAL RESULTS).
ISSUE TYPE
- Bug Report
COMPONENT NAME
win_psmodule
ANSIBLE VERSION
ansible [core 2.16.0]
config file = /home/user/.ansible.cfg
configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/user/env/ansible/lib64/python3.11/site-packages/ansible
ansible collection location = /opt/user/ansible/collections
executable location = /opt/user/env/ansible/bin/ansible
python version = 3.11.11 (main, Dec 9 2024, 15:32:27) [GCC 8.5.0 20210514 (Red Hat 8.5.0-22)] (/opt/user/env/ansible/bin/python3.11)
jinja version = 3.1.2
libyaml = True
COLLECTION VERSION
# /opt/user/ansible/collections/ansible_collections
Collection Version
----------------- -------
community.windows 2.0.0
# /opt/user/env/ansible/lib/python3.11/site-packages/ansible_collections
Collection Version
----------------- -------
community.windows 2.0.0
# /opt/user/env/ansible/lib64/python3.11/site-packages/ansible_collections
Collection Version
----------------- -------
community.windows 2.0.0
CONFIGURATION
COLLECTIONS_PATHS(/home/user/.ansible.cfg) = ['/opt/user/ansible/collections']
CONFIG_FILE() = /home/user/.ansible.cfg
OS / ENVIRONMENT
Target OS: Windows Server 2019
STEPS TO REPRODUCE
- Register a repository containing a module also found in PSGallery
- Running
Find-Module -Name $Name
, where $Name is the duplicate module, should now return two lines:
PS > Find-Module -Name Microsoft.Graph
Version Name Repository Description
------- ---- ---------- -----------
2.29.1 Microsoft.Graph PSGallery Microsoft Graph PowerShell module
2.26.1 Microsoft.Graph PSGalleryCopy Microsoft Graph PowerShell module
Now running a playbook with the following task fails:
- name: Add Microsoft.Graph PowerShell module
community.windows.win_psmodule:
name: Microsoft.Graph # replace with the duplicate module
accept_license: true # only needed, because this example uses Microsoft.Graph
state: latest
EXPECTED RESULTS
Three solutions come to mind:
- Always install from the repository containing the highest version
- Throw an error indicating the module exists on multiple defined repositories
- Throw an error suggesting the user to define a repository
I would tend for solutions 2 or 3
ACTUAL RESULTS
This error is returned
The full traceback is:
Cannot process argument transformation on parameter 'RequiredVersion'. Cannot convert value to type System.String.
At line:485 char:26
+ Install-PsModule @ht
+ ~~~
+ CategoryInfo : InvalidData: (:) [Install-PsModule], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Install-PsModule
ScriptStackTrace:
at <ScriptBlock>, <No file>: line 485
fatal: [hostname]: FAILED! => {
"changed": false,
"msg": "Unhandled exception while executing module: Cannot process argument transformation on parameter 'RequiredVersion'. Cannot convert value to type System.String."
}
WORKAROUND
Define the repository in the win_psmodule task
Metadata
Metadata
Assignees
Labels
No labels