mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 11:21:25 -07:00
windows: add #AnsibleRequires for Windows modules (#31683)
* windows: add #AnsibleRequires to set whether a module requires module or a specific version * fix up pep8 issues * changed psversion to use the actual ps Requires -Version syntax * missed the check on #Requires -Version * fix #Requires module extensions
This commit is contained in:
parent
0c34cdd0f7
commit
b004a6373a
8 changed files with 203 additions and 7 deletions
|
@ -71,6 +71,26 @@ end {
|
|||
# TODO: handle binary modules
|
||||
# TODO: handle persistence
|
||||
|
||||
$min_os_version = [version]$payload.min_os_version
|
||||
if ($min_os_version -ne $null) {
|
||||
$actual_os_version = [System.Environment]::OSVersion.Version
|
||||
if ($actual_os_version -lt $min_os_version) {
|
||||
$msg = "This module cannot run on this OS as it requires a minimum version of $min_os_version, actual was $actual_os_version"
|
||||
Write-Output (ConvertTo-Json @{failed=$true;msg=$msg})
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
$min_ps_version = [version]$payload.min_ps_version
|
||||
if ($min_ps_version -ne $null) {
|
||||
$actual_ps_version = $PSVersionTable.PSVersion
|
||||
if ($actual_ps_version -lt $min_ps_version) {
|
||||
$msg = "This module cannot run as it requires a minimum PowerShell version of $min_ps_version, actual was $actual_ps_version"
|
||||
Write-Output (ConvertTo-Json @{failed=$true;msg=$msg})
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
$actions = $payload.actions
|
||||
|
||||
# pop 0th action as entrypoint
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue