win_partition - Fix handling of maximum partition size (#58225)
* Fix handling of maximum partition size * Added changelog fragment
This commit is contained in:
parent
53ba3c46cc
commit
7dfd994a7e
2 changed files with 8 additions and 9 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- win_partition - don't resize partitions if size difference is < 1 MiB
|
|
@ -148,13 +148,8 @@ function New-AnsiblePartition {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($SizeMax) {
|
if ($null -ne $Size) {
|
||||||
$True {
|
$parameters.Add("Size", $Size)
|
||||||
$parameters.Add("UseMaximumSize", $True)
|
|
||||||
}
|
|
||||||
$False {
|
|
||||||
$parameters.Add("Size", $Size)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($null -ne $MbrType) {
|
if ($null -ne $MbrType) {
|
||||||
|
@ -235,7 +230,7 @@ if ($ansible_partition) {
|
||||||
if ($size_is_maximum) {
|
if ($size_is_maximum) {
|
||||||
$ansible_partition_size = $max_supported_size
|
$ansible_partition_size = $max_supported_size
|
||||||
}
|
}
|
||||||
if ($ansible_partition_size -ne $ansible_partition.Size -and $ansible_partition_size -le $max_supported_size) {
|
if ($ansible_partition_size -ne $ansible_partition.Size -and ($ansible_partition_size - $ansible_partition.Size -gt 1049000 -or $ansible_partition.Size - $ansible_partition_size -gt 1049000)) {
|
||||||
if ($ansible_partition.IsReadOnly) {
|
if ($ansible_partition.IsReadOnly) {
|
||||||
$module.FailJson("Unable to resize partition: Partition is read only")
|
$module.FailJson("Unable to resize partition: Partition is read only")
|
||||||
} else {
|
} else {
|
||||||
|
@ -281,6 +276,8 @@ else {
|
||||||
if ($ansible_partition_size -gt $max_supported_size) {
|
if ($ansible_partition_size -gt $max_supported_size) {
|
||||||
$module.FailJson("Partition size is not supported by disk. Use partition_size: -1 to get maximum size")
|
$module.FailJson("Partition size is not supported by disk. Use partition_size: -1 to get maximum size")
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$ansible_partition_size = (Get-Disk -Number $disk_number).LargestFreeExtent
|
||||||
}
|
}
|
||||||
|
|
||||||
$supp_part_type = (Get-Disk -Number $disk_number).PartitionStyle
|
$supp_part_type = (Get-Disk -Number $disk_number).PartitionStyle
|
||||||
|
@ -300,7 +297,7 @@ else {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-not $module.CheckMode) {
|
if (-not $module.CheckMode) {
|
||||||
$ansible_partition = New-AnsiblePartition -DiskNumber $disk_number -Letter $drive_letter -SizeMax $size_is_maximum -Size $ansible_partition_size -MbrType $mbr_type -GptType $gpt_type -Style $partition_style
|
$ansible_partition = New-AnsiblePartition -DiskNumber $disk_number -Letter $drive_letter -Size $ansible_partition_size -MbrType $mbr_type -GptType $gpt_type -Style $partition_style
|
||||||
}
|
}
|
||||||
$module.Result.changed = $true
|
$module.Result.changed = $true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue