Using parted module ..I am unable to create multiple partitions on the disk.

101 views
Skip to first unread message

coach...@gmail.com

unread,
Oct 17, 2017, 12:09:20 AM10/17/17
to Ansible Project
Hi,

I have a query here and request your help .I am trying to create multiple partition on the disk with parted module , but it only creates one partition. Is parted module creates only one partition of the entire disk or is there is way to achieve this.

 - name: create of partitions
   parted: "label=gpt device=/dev/sdb state=present number=2 unit=MiB part_end=1GiB"

when try to create on more partition on the disk gives the below error.

[student@puppetclient ~]$  ansible 192.168.3.157 -m parted -a "device=/dev/sdb number=3 state=present part_end=1GB"
192.168.3.157 | FAILED! => {
    "changed": false,
    "err": "Error: You requested a partition from 0.00kiB to 976563kiB (sectors 0..1953125).\nThe closest location we can manage is 17.0kiB to 1024kiB (sectors 34..2047).\n",
    "failed": true,
    "msg": "Error while running parted script: /sbin/parted -s -m -a optimal /dev/sdb -- unit KiB mkpart primary 0% 1GB",
    "out": "",
    "rc": 1


Thank you for looking into it.

mcso...@redhat.com

unread,
Oct 19, 2017, 4:09:45 AM10/19/17
to Ansible Project
This looks like you are trying to create overlapping partitions. I have not tried it, but to me looks like you need to add `part_start=1GB part_end=2GB`

coach...@gmail.com

unread,
Oct 21, 2017, 12:15:35 AM10/21/17
to Ansible Project


On Thursday, October 19, 2017 at 1:39:45 PM UTC+5:30, mcso...@redhat.com wrote:
This looks like you are trying to create overlapping partitions. I have not tried it, but to me looks like you need to add `part_start=1GB part_end=2GB`

Thank you for looking into it. but i am unable to create multiple partitions.Although I gave the part_start and part_end as mentioned by you (( ansible test -m parted -a "device=/dev/sdb number=3 part_start=3GB part_end=4GB")) but it doesnot create a new partition. already have two partitions on the test host on /dev/sdb..below snippet. I am trying to create a third partition sdb3 with parted module..does work ...

# lsblk
NAME                       MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                          8:0    0   30G  0 disk
├─sda1                       8:1    0  300M  0 part /boot
├─sda2                       8:2    0    3G  0 part [SWAP]
└─sda3                       8:3    0 26.7G  0 part /
sdb                          8:16   0    5G  0 disk
├─sdb1                       8:17   0  953M  0 part
└─sdb2                       8:18   0    1G  0 part
  └─oravg-oralv            253:0    0 1000M  0 lvm  /oradata1
sr0                         11:0    1 53.3M  0 rom
sr1                         11:1    1    4G  0 rom  /mnt



 

coach rhca

unread,
Oct 21, 2017, 1:35:54 AM10/21/17
to ansible...@googlegroups.com
`Thank you for help...I was able to figure out...

--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/BgkLzoVZn1I/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/0e2e1688-8b23-4693-aebe-89a289e7b318%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kai Stian Olstad

unread,
Oct 21, 2017, 4:22:24 AM10/21/17
to ansible...@googlegroups.com
On 21. okt. 2017 07:35, coach rhca wrote:
> `Thank you for help...I was able to figure out...

In open source community it's custom to share the answer you find, we are here to help each other.

Think about it, if you are the one searching for the answer and find someone else with the exact same problem, only to find "got it" as an answer.


--
Kai Stian Olstad

dwill...@gmail.com

unread,
Oct 23, 2017, 2:33:34 PM10/23/17
to Ansible Project
Haven't found much on Google about creating multiple partitions. You will have to workout the disk dimensions, but this worked for me:

---
- name: Create partition 1
  parted:
    device: /dev/xvdb
    number: 1
    state: present
    part_end: 1GiB

- parted:
    device: /dev/xvdb
    number: 2
    state: present
    part_start: 1GiB
    part_end: 31GiB

- parted:
    device: /dev/xvdb
    number: 3 
    state: present
    part_start: 31GiB
    part_end: 61GiB

- parted:
    device: /dev/xvdb
    number: 4
    state: present
    part_start: 61GiB
    part_end: 101GiB

- parted:
    device: /dev/xvdb
    number: 5
    state: present
    part_start: 101GiB
    part_end: 111GiB

- parted:
    device: /dev/xvdb
    number: 6
    state: present
    part_start: 111GiB
    part_end: 100%



 

coach rhca

unread,
Oct 24, 2017, 7:45:53 AM10/24/17
to ansible...@googlegroups.com
Sure..I did not  mentioning the number correctly which is required for the partitioning...the partition already created was giving error...so changing the number did the work for me...also
I am looking for how to add a logical partitions in the extended ones..Thank you for highlighting and looking into it..

--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/BgkLzoVZn1I/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages