ansible-collections / community.general

Ansible Community General Collection
https://galaxy.ansible.com/ui/repo/published/community/general/
GNU General Public License v3.0
814 stars 1.49k forks source link

proxmox: what is the proper syntax for the "disk" parameter for a LXC container #6027

Open johanneskastl opened 1 year ago

johanneskastl commented 1 year ago

Summary

Creating an LXC container on a proxmox host only works if I omit the disk parameter. I have not found any syntax that is being accepted by my proxmox host.

The Proxmox documentation on LXC containers mentions that the rootfs argument should be something like this:

thin1:base-100-disk-1,size=8G

So it is name of the local storage, then a colon, then some name, then a comma, and then size=8GB. I also see a similar output in my existing lxc contains in the proxmox GUI.

However, no matter what I specify in the disk option I get not a valid disk size: 2GB\\n\\n.

Issue Type

Bug Report

Component Name

proxmox.py

Ansible Version

$ ansible --version
ansible [core 2.14.2]

Community.general Version

$ ansible-galaxy collection list community.general
# /usr/lib/python3.10/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 6.3.0 

Configuration

No response

OS / Environment

openSUSE Tumbleweed, python3.10

Steps to Reproduce

I tried multiple things for the disk parameter (my storage seems to be called local-lvm):

- name: Create new container with minimal options
  community.general.proxmox:
    vmid: 100
    node: ...
   [...]
    hostname: example.org
    ostemplate: 'local:vztmpl/ubuntu-14.04-x86_64.tar.gz'
    disk: '???'

Expected Results

I would like to be able to set the size of the disk that is being allocated.

Actual Results

[...]
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Creation of lxc VM 108 failed with exception: 400 Bad Request: Parameter verification failed. - {'rootfs': 'invalid format - format error\\nrootfs.size: invalid format - value does not look like a valid disk size: 2GB\\n\\n'}"}

Code of Conduct

ansibullbot commented 1 year ago

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot commented 1 year ago

cc @Ajpantuso @Thulium-Drake @UnderGreen @joshainglis @karmab @tleguern click here for bot help

raiyni commented 1 year ago

It's like

disk: 'local-zfs:3'

with local-zfs being the storage name in proxmox that can store containers and then the size in gb

lildadou commented 1 year ago

You can select a pre-allocated volume via

disk: 'storage-provider:volume-name'

but you MUST do NOT define the parameter storage

johanneskastl commented 1 year ago

Thanks @raiyni @lildadou, that answers my questions. I have tested @raiyni 's way and it works.

If I find time, I'll try to adapt the documentation.

felixfontein commented 1 year ago

PRs for improving the docs are always welcome! :)

felixfontein commented 9 months ago

7685 is a PR that improves this by adding a new example. I would be glad if some others who are familiar with the disk option can take a look at it! Thanks :)

ansibullbot commented 7 months ago

cc @krauthosting click here for bot help