Open iasllanih opened 2 years ago
AFAIK Find-Module
will be used to find modules on a remote repository not tell you what is installed. You want Get-Module -Name PowerShellGet -ListAvailable
to see what is installed. PowerShellGet is installed by default but you may need to update it to support newer features the module relies on.
AFAIK
Find-Module
will be used to find modules on a remote repository not tell you what is installed. You wantGet-Module -Name PowerShellGet -ListAvailable
to see what is installed. PowerShellGet is installed by default but you may need to update it to support newer features the module relies on.
Thanks for the tip... strange thing is, why was it working on Ansible 2.9 with no error?
Thanks!
And im using the same ami and running the exact same role, so the image itself is not any different
Just looked at it - that module isn't doing anything special, it is just calling the Import-Module
command, as such:
if (-not (Import-Module -Name PowerShellGet -MinimumVersion 1.6.0 -PassThru -ErrorAction SilentlyContinue)) {
Fail-Json -obj $result -Message "PowerShellGet version 1.6.0+ is required."
}
@iasllanih If you want to troubleshoot, run Import-Module -Name PowerShellGet -MinimumVersion 1.6.0 -PassThru
on the server you are having issues with - should hopefully give you a better idea of what is going on. Either way, if it is a bug, it is likely a bug with the Import-Module
command, and not with the community.windows.win_psrepository
module.
@jborean93 Should we add PS error details to the output? Like:
if (-not (Import-Module -Name PowerShellGet -MinimumVersion 1.6.0 -PassThru -ErrorAction SilentlyContinue -ErrorVariable moduleErr)) {
Fail-Json -obj $result -Message "PowerShellGet version 1.6.0+ is required. $($moduleErr.Exception)"
}
Ran into the same issue and did a comparison.
In Ansible 2.9, ansible.windows.win_psrepository.ps1
does not have this check as it was not a requirement at that time. While base functionality still works, the upgraded PowerShellGet
adds additional functionality which is required by features since added. As such this is not a bug, but a change in requirements.
Just out of curiosity what is intended use area for this module? Windows server 2022 by default comes with PowerShell 5.1 so it does now meet requirements:
Do I have to install PowerShell 7 on mine Windows servers, or do I have to upgrade these modules manually, before I can orchestrate them using Ansible? How others overcome there requirements on their servers?
SUMMARY
win_psrepository throwing error
fatal: [molecule--windows-base-role-srv19-01]: FAILED! => { "changed": false, "msg": "PowerShellGet version 1.6.0+ is required." }
(his does not happen on ansible 2.9 (We are trying to upgrade)
ISSUE TYPE
COMPONENT NAME
community.windows.win_psrepository
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
Windows 2016 public AMI
STEPS TO REPRODUCE
Run the module
EXPECTED RESULTS
Powershell repo to be configured
ACTUAL RESULTS
Error complaining about powershellget version not being 1.6.0+, but it is ` PS C:\Windows\system32> Find-Module -Name PowerShellGet
Version Name Repository Description
2.2.5 PowerShellGet PSGallery PowerShell module with commands for discovering,... `
Not only does this module work perfectly fine in 2.9, i can manually add the repo as well.