Unable to create the partition

114 views
Skip to first unread message

Ashok Reddy

unread,
Jul 8, 2022, 4:04:56 AM7/8/22
to Ansible Project
Hi,

I am trying to create the partition, but got the following error:

---

- hosts: default

  become: true

  become_method: sudo

  tasks:

    - name: part1

      parted:

        device: "/dev/vdb"

        number: 1

        state: present

    - name: filesystem

      filesystem:

        fstype: ext4

        dev: /dev/vdb

    - name: mounted

      mount:

        path: /opt

        src: /dev/vdb

        fstype: ext4

        state: mounted


    - name: partition

      lvg:

        vg: "datavg"

        pvs: "/dev/vdb"

        state: present

    - name: resize pv

      command: "pvresize /dev/vdb"


    - name: activate vg

      command: "vgchange -a y datavg"


    - name: Ensure

      lvol:

        vg: datavg

        lv: datalv

        size: "100%FREE"

      ignore_errors: true


    - name: sql file

      filesystem:

        dev: "/dev/datavg/datalv"

        fstype: ext4

Error:

TASK [part1] **********************************************************************************************************************************************************************************************

fatal: [localhost]: FAILED! => {"changed": false, "err": "Error: Could not stat device /dev/vdb - No such file or directory.\n", "msg": "Error while getting device information with parted script: '/sbin/parted -s -m /dev/vdb -- unit 'KiB' print'", "out": "", "rc": 1}



Stefan Hornburg (Racke)

unread,
Jul 8, 2022, 4:36:16 AM7/8/22
to ansible...@googlegroups.com
On 08/07/2022 10:04, Ashok Reddy wrote:
> Hi,
>
> I am trying to create the partition, but got the following error:

I think that the error message is clear about the problem. The device doesn't exist.

Regards
Racke
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/3a39c550-240b-40c9-ac52-508089cd14c4n%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/3a39c550-240b-40c9-ac52-508089cd14c4n%40googlegroups.com?utm_medium=email&utm_source=footer>.


--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper

Ashok Reddy

unread,
Jul 8, 2022, 5:50:36 AM7/8/22
to Ansible Project
I am trying to create new partition.
If that is not available, so that only need to create the /dev/vdb partition.

Dick Visser

unread,
Jul 8, 2022, 7:48:41 AM7/8/22
to ansible...@googlegroups.com


On 2022-07-08 (Fri) 11:50, Ashok Reddy wrote:
> I am trying to create new partition.
> If that is not available, so that only need to create the /dev/vdb
> partition.

Your logic is flawed.
You cannot create devices.
You can only create partitions on existing devices.



OpenPGP_0x266713D4E6EF488D.asc
OpenPGP_signature

Ashok Reddy

unread,
Jul 11, 2022, 1:22:11 AM7/11/22
to Ansible Project
Thanks for providing your input.

Ashok Reddy

unread,
Jul 11, 2022, 2:10:01 AM7/11/22
to Ansible Project

lsblk

NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT

vda    252:0    0   50G  0 disk

├─vda1 252:1    0  500M  0 part /boot

├─vda2 252:2    0    4G  0 part [SWAP]

└─vda3 252:3    0 10.5G  0 part /


---

- hosts: default

  become: true

  become_method: sudo

  tasks:

    - name: part1

      parted:

        device: "/dev/vda1"

        number: 1

        state: present

    - name: filesystem

      filesystem:

        fstype: ext4

        dev: /dev/vda1

    - name: mounted

      mount:

        path: /opt

        src: /dev/vda1

        fstype: ext4

        state: mounted


    - name: partition

      lvg:

        vg: "datavg"

        pvs: "/dev/vda1"

        state: present

    - name: resize pv

      command: "pvresize /dev/vda1"


    - name: activate vg

      command: "vgchange -a y datavg"


    - name: Ensure

      lvol:

        vg: datavg

        lv: datalv

        size: "100%FREE"

      ignore_errors: true


    - name: sql file

      filesystem:

        dev: "/dev/datavg


error:

TASK [part1] **********************************************************************************************************************************************************************************************

fatal: [localhost]: FAILED! => {"changed": false, "err": "Error: Partition(s) on /dev/vda1 are being used.\n", "msg": "Error while running parted script: /sbin/parted -s -m -a optimal /dev/vda1 -- unit KiB mklabel msdos mkpart primary 0% 100%", "out": "", "rc": 1}

David Logan

unread,
Jul 11, 2022, 2:15:25 AM7/11/22
to Ansible Project
You appear to be trying to do something to the /boot partition.

Perhaps you are referring to the wrong device?



When in trouble, or in doubt
Run in circles, scream and shout

Ashok Reddy

unread,
Jul 11, 2022, 2:28:01 AM7/11/22
to Ansible Project
Can you please suggest me how to fix this issue?

David Logan

unread,
Jul 11, 2022, 3:07:30 AM7/11/22
to Ansible Project
On the systems that I build, the /boot partition is simply an ext4 or xfs file system. I would not be trying to use logical volume manager to try to build /boot.

I would also look at using a kick-start method or similar to automate the build and get the file systems built there rather than with ansible.

Anyway that is what I do, others may have a different method that may work better in your case.

When in trouble, or in doubt
Run in circles, scream and shout

Ashok Reddy

unread,
Jul 11, 2022, 5:27:59 AM7/11/22
to ansible...@googlegroups.com
Thanks for providing your input.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/54e13f42-7926-44d1-a6f3-a2f0ae4830d9%40gmail.com.
Reply all
Reply to author
Forward
0 new messages