[SOLVED] Resize Disk with Ansible

Mar 28, 2020
11
1
23
58
I'm not sure if this is an Ansible, or a Proxmox question, but I've got to start somewhere...

I can create and/or clone a QEMU VM in Proxmox using Ansible's community.general.proxmox_kvm module. However, that module's documentation specifically states that it cannot resize a disk.

I therefore tried to use qm resize <vm> <disk> <new size> from Ansible. I used the command, shell and raw modules in turn and they all failed with:

JSON:
    "invocation": {
        "module_args": {
            "_raw_params": "/usr/sbin/qm resize 100 scsi0 3G",
            "_uses_shell": false,
            "argv": null,
            "chdir": null,
            "creates": null,
            "executable": null,
            "removes": null,
            "stdin": null,
            "stdin_add_newline": true,
            "strip_empty_ends": true,
            "warn": false
        }
    },
    "msg": "non-zero return code",
    "rc": 21,
    "start": "2021-10-13 07:57:11.688857",
    "stderr": "ipcc_send_rec[1] failed: Is a directory\nipcc_send_rec[2] failed: Is a directory\nipcc_send_rec[3] failed: Is a directory\nUnable to load access control list: Is a directory",
    "stderr_lines": [
        "ipcc_send_rec[1] failed: Is a directory",
        "ipcc_send_rec[2] failed: Is a directory",
        "ipcc_send_rec[3] failed: Is a directory",
        "Unable to load access control list: Is a directory"

Ignoring the crud, the pertinent lines above are the code being ran /usr/sbin/qm resize 100 scsi0 3G, the return code (21) and the ipcc_send_rec messages.

I realise that the command needs to be run as the root user so I've used the become directive within the playbook:

I've tried the default, which is to use sudo:
Code:
become: yes

And I've tried used a variation which uses su:
Code:
become: yes
become_method: su

Both fail.

The command itself works as I can SSH in and run the command, with the root account or with a normal account and sudo. Also, other non Proxmox related Ansible commands which require privilege elevation work.

As background, this is on a recently rebuilt Proxmox host with no live data. I therefore re-installed this morning, just in-case I'd inadvertently meddled with something and broken it. This is a standalone Proxmox instance - no clustering. I also tried on another Proxmox instance and got the same results.

I could potentially use Ansible to manipulate the Proxmox REST API, but it would be much simpler if I could get a simple command to work.

Any ideas?

Thanks.
 
on pve 6.4 with ansible 2.7 it's working out of the box...also with command module

Code:
ansible -b -D --ask-vault-pass -vvv -m shell -a "qm resize 102 scsi0 5G" HOST

HOST | CHANGED | rc=0 >>
  Size of logical volume elastic/vm-102-disk-0 changed from 4.00 GiB (1024 extents) to 5.00 GiB (1280 extents).
  Logical volume elastic/vm-102-disk-0 successfully resized.
 
on pve 6.4 with ansible 2.7 it's working out of the box...also with command module

Code:
ansible -b -D --ask-vault-pass -vvv -m shell -a "qm resize 102 scsi0 5G" HOST

HOST | CHANGED | rc=0 >>
  Size of logical volume elastic/vm-102-disk-0 changed from 4.00 GiB (1024 extents) to 5.00 GiB (1280 extents).
  Logical volume elastic/vm-102-disk-0 successfully resized.
Good spot! I'm was only using playbooks. Running Ansible directly as you did also worked for me. I've now got to work out why it works in Ansible, but not in Ansible playbooks. My plan is to use a playbook to clone a cloud-init VM and configure it. The cloned VM has a minimal 2G SCSI disk image which I want to expand to a size which depends on the end task of the VM.
 
Apologies for wasting people's time. This turned out to be an Ansible issue, or more specifically, the Ansible operator (me). A typo in my playbook meant that the script wasn't being run as root.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!