Stone Monarch
Stone Monarch

Reputation: 395

Ansible community parted module asking "Are you sure you want to continue", is there an override

I am trying to expand an ext4 partition to fill a disk on Alpine using Ansible.

Following the community parted module documentation here I should be able too. However when it comes to performing that action the returned error message says "Warning: Partition /dev/xvda3 is being used. Are you sure you want to continue?\n".

Is there anyway to force this action to proceed on a live system as it looks like Parted is asking for user interaction even though the -s flag is enable?

The task I'm using:

 - name: Read device information
  community.general.parted: device=/dev/xvda unit=MiB
  register: sdb_info

 - name: Extend an existing partition to fill all available space
  community.general.parted:
    device: /dev/xvda
    number: "{{ sdb_info.partitions | length }}"
    part_end: "100%"
    resize: true
    state: present

The full error from ansible-playbook main.yaml -vvvv:

fatal: [10.10.30.100]: FAILED! => {
    "changed": false,
    "err": "Warning: Partition /dev/xvda3 is being used. Are you sure you want to continue?\n",
    "invocation": {
        "module_args": {
            "align": "optimal",
            "device": "/dev/xvda",
            "flags": null,
            "fs_type": null,
            "label": "msdos",
            "name": null,
            "number": 3,
            "part_end": "100%",
            "part_start": "0%",
            "part_type": "primary",
            "resize": true,
            "state": "present",
            "unit": "KiB"
        }
    },
    "msg": "Error while running parted script: /usr/sbin/parted -s -m -a optimal /dev/xvda -- resizepart 3 100%",
    "out": "",
    "rc": 1
}

Target host:

Local:

Upvotes: 4

Views: 2364

Answers (1)

U880D
U880D

Reputation: 12145

According the documentation community.general and source code community.general/blob/main/plugins/modules/system/parted.py, the module is just a wrapper around the Linux tool parted.

Looking into other similar reports like Ubuntu Launchpad #1270203, the confirmation question

Warning: Partition <part> is being used. Are you sure you want to continue?

seems to be the normal and expected behavior if one tries to resizepart on a mounted partition.

Ansible community parted module asking "Are you sure you want to continue"

So it is not community module which is asking, but the Linux tool parted itself.

is there an override

In the community module itself is currently neither this corner case covered, nor an override implemented yet. Therefore the error message is thrown.

You could

  • either try to unmount the partition before and mount after resize again with mount module – Control active and configured mount points
  • or use the shell module with cmd: /usr/sbin/parted -s -m -a optimal /dev/xvda -- resizepart 3 yes 100% (... or yes | ...) as mentioned in the thread #1270203
  • or enhance the behavior of the module by patching and extending the source parted.py accordingly

Upvotes: 0

Related Questions