I get the below error while trying to partition a managed azure disk that has been attached to a VM
TASK [role_azure_disk : Partition Azure Disk] ***********************************************************************************************************************************************************************************************
task path: /etc/ansible/roles/role_azure_disk/tasks/main.yml:7
fatal: [labserver]: FAILED! => {"changed": false, "err": "Error: Could not stat device /dev/sdc - No such file or directory.\n", "msg": "Error while getting device information with parted script: '/sbin/parted -s -m /dev/sdc -- unit 'KiB' print'", "out": "", "rc": 1}
The task is a simple task shown below:
- name: Partition Azure Disk
parted:
device: /dev/sdc
number: 1
state: present
when: provider == "azure"
The device has no label as reported by parted (below) but can be formatted manually using fdisk.
Error: /dev/sdc: unrecognised disk label Model: Msft Virtual Disk (scsi) Disk /dev/sdc: 18.3GB Sector size (logical/physical): 512B/4096B Partition Table: unknown Disk Flags:
Not sure if this is an issue with parted or I'm doing this wrong?
I'm trying to avoid using fdisk passed to the shell module i.e.
(echo n; echo p; echo 1; echo ; echo ; echo w) | sudo fdisk /dev/sdc
Thanks