Skip to content

win_format fails for spanned partition #644

@warrence2471

Description

@warrence2471
SUMMARY

windows.community.win_format module seems to not work with spanned partitions.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

windows.community.win_format module

ANSIBLE VERSION
ansible [core 2.17.12]
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.10/dist-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.10.12 (main, May 27 2025, 17:12:29) [GCC 11.4.0] (/usr/bin/python3)
  jinja version = 3.1.6
  libyaml = True
COLLECTION VERSION
Collection        Version
----------------- -------
community.windows 2.3.0
CONFIGURATION
CONFIG_FILE() = None
OS / ENVIRONMENT

Microsoft Windows 11 Enterprise 10.0.26100 Build 26100

STEPS TO REPRODUCE

I try to run win_format on several Windows 11 hosts for a partition with spanned layout and dynamic type.

Image

Running the following task on this machine returns an error (see below).

    - name: Quick-format physical drive.
      community.windows.win_format:
        drive_letter: F
        new_label: mynewlabel

In my troubleshooting attempts I found that Get-Partition does not return the partition, but Get-Volume returns a volume for the drive letter.

PS C:\> Get-Partition

   DiskPath: \\?\scsi#disk&ven_ata&prod_micron_1300_sata#4&2cc633b5&0&020000#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}

PartitionNumber  DriveLetter Offset                                        Size Type
---------------  ----------- ------                                        ---- ----
1                           1048576                                     500 MB System
2                           525336576                                   128 MB Reserved
3                C           659554304                                475.66 GB Basic
4                           511391563776                                684 MB Recovery

PS C:\> Get-Volume

DriveLetter FriendlyName FileSystemType DriveType HealthStatus OperationalStatus SizeRemaining      Size
----------- ------------ -------------- --------- ------------ ----------------- -------------      ----
C           Windows      NTFS           Fixed     Healthy      OK                    275.84 GB 475.66 GB
                         NTFS           Fixed     Healthy      OK                    101.31 MB    684 MB
F           Projects     NTFS           Fixed     Healthy      OK                      2.75 TB   3.44 TB

Doing a manual quick format via right-click and "Format..." in Windows Explorer on the host works fine.

It seems to work fine for other partitions on Windows 11 hosts that have simple layout and basic type.

EXPECTED RESULTS

No error, and the partition is formatted.

ACTUAL RESULTS

Running win_format on the spanned drive yields the following error.

TASK [Quick-format physical drive.] *****************************************************************************************************************************************************************************
task path: /etc/ansible/playbooks/decommission-buildmachine.yml:107
Using module file /usr/local/lib/python3.10/dist-packages/ansible_collections/community/windows/plugins/modules/win_format.ps1
Pipelining is enabled.
<MYHOST> ESTABLISH WINRM CONNECTION FOR USER: ******** on PORT *** TO MYHOST
calling kinit with subprocess for principal ********
EXEC (via pipeline wrapper)
The full traceback is:
No MSFT_Partition objects found with property 'DriveLetter' equal to 'f'.  Verify the value of the property and retry.
At line:82 char:26
+ ...          $partition = Get-Partition -DriveLetter $DriveLetter | Where ...
+                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (f:Char) [Get-Partition], CimJobException
    + FullyQualifiedErrorId : CmdletizationQuery_NotFound_DriveLetter,Get-Partition

ScriptStackTrace:
fatal: [MYHOST]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "allocation_unit_size": null,
            "compress": null,
            "drive_letter": "f",
            "file_system": null,
            "force": false,
            "full": false,
            "integrity_streams": null,
            "label": null,
            "large_frs": null,
            "new_label": "Projects",
            "path": null
        }
    },
    "msg": "There was an error retrieving the volume using drive_letter f: No MSFT_Partition objects found with property 'DriveLetter' equal to 'f'.  Verify the value of the property and retry."
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions