0

I wanted to create a partition /dev/sdb2 on an empty disk. Ansible task looks as below:

   community.general.parted:
     device: "/dev/sdb"
     number: "2"
     state: present
     part_end: "100%"
     fs_type: xfs
     part_type: primary

Ansible parted runs this line according to a message it throws when i want to make it for 2nd time: /sbin/parted -s -m -a optimal /dev/sdb -- unit KiB mkpart primary xfs 0% 100%'

The number property, does not look like it is changing something. It is always making sdb1, am i doing something wrong ? Or maybe it was never supposed to support that number ? According to documentation this number should make the desired partition number. "The number of the partition to work with or the number of the partition that will be created."

ansible [core 2.11.6]
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /root/venv/lib/python3.9/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /root/venv/bin/ansible
  python version = 3.9.7 (default, May 10 2022, 23:45:56) [GCC 8.5.0 20210514 (Red Hat 8.5.0-10)]
  jinja version = 2.11.3
  libyaml = True
Gregu
  • 115
  • 5

1 Answers1

0

I am not sure you can set partition on the way you want. The simplest you can do is to create small (20-50MB) partition to get position 1 and then create on the rest of the disk second partition.

Romeo Ninov
  • 6,538
  • 1
  • 22
  • 31
  • Right, its just that either i am readying the documentation for this module incorrectly, or it should be fixed in that case not to mislead the user. I saw on stackoverflow echo-e "n\np\n2\n\n\nw"| sudo fdisk /dev/sdb this kind of solution, which would work just fine, but it thought it;s just me running this module incorrectly. – Gregu Jul 19 '22 at 07:18