Skip to content

proxmox: Handling of disk_volume variable is broken #9065

Open
@aacater

Description

Summary

I noticed a few problems when trying to create a lxc with this module:

  1. disk_volume is currently passed to proxmoxer. However, the correct variable name in proxmoxer name is rootfs.

Changing disk_volume=module.params["disk_volume"], to rootfs=module.params["disk_volume"], fixes this issue.

  1. storage is currently marked mutually exclusive with disk_volume. However, disk_volume.storage does not seem to be honored and the module tries to create the rootfs on the default local.

Making storage no longer mutually exclusive with disk_volume allows the lxc to be properly created. So disk_volume.storage is unneeded and unused. At least I think so. In the proxmox api docs, rootfs doesn't have a storage field. EDIT: This is true but to set the destination storage, you can do rootfs: "data-zfs:8" for example.

But there is a lot of logic for transforming the input variables into what is actually passed to proxmoxer. So maybe the intention is to use disk_volume.storage and its just a bug that its not used.

  1. disk_volume.size is not honored. The module always creates a 4 GB disk.

Issue Type

Bug Report

Component Name

proxmox

Ansible Version

$ ansible --version
ansible [core 2.17.5]
  config file = /workspaces/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.11/dist-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.11.2 (main, Aug 26 2024, 07:20:54) [GCC 12.2.0] (/usr/bin/python3)
  jinja version = 3.1.4
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general
Collection        Version
----------------- -------
community.general 9.5.0

Configuration

$ ansible-config dump --only-changed
ANSIBLE_FORCE_COLOR(env: ANSIBLE_FORCE_COLOR) = True
CONFIG_FILE() = /workspaces/ansible/ansible.cfg
DEFAULT_HOST_LIST(/workspaces/ansible/ansible.cfg) = ['/workspaces/ansible/inventory']
DEFAULT_LOCAL_TMP(/workspaces/ansible/ansible.cfg) = /tmp/ansible-local-761129b7jaj5
DEFAULT_PRIVATE_KEY_FILE(/workspaces/ansible/ansible.cfg) = /root/.ssh/aacater
DEFAULT_ROLES_PATH(/workspaces/ansible/ansible.cfg) = ['/root/.ansible/roles', '/workspaces/ansible/roles']
DEFAULT_STDOUT_CALLBACK(/workspaces/ansible/ansible.cfg) = community.general.yaml
DEFAULT_VAULT_PASSWORD_FILE(/workspaces/ansible/ansible.cfg) = /workspaces/ansible/.vault_pass
HOST_KEY_CHECKING(/workspaces/ansible/ansible.cfg) = False
INTERPRETER_PYTHON(/workspaces/ansible/ansible.cfg) = /usr/bin/python3

OS / Environment

Client: Custom Podman container based on Debian 12
Proxmox Server: pve-manager/8.2.7/3e0176e6bb2ade3b (running kernel: 6.8.8-4-pve)

Steps to Reproduce

---
- name: Create lxc on pve
  hosts: localhost
  tasks:
    - name: Deploy container
      community.general.proxmox:
        api_host: "{{ pve_host_ip }}"
        api_user: "{{ pve_host_api_user }}"
        api_password: "{{ pve_host_api_pass }}"
        validate_certs: false
        node: pve1
        hostname: test
        unprivileged: true
        pubkey: "{{ pve_lxc_ssh_pubkey }}"
        vmid: 999
        state: present
        ostemplate: "templates:vztmpl/debian-12-standard_12.2-1_amd64.tar.zst"

        # storage: data-zfs

        disk_volume:
          size: "8" # ignored
          storage: INVALID # unused

Expected Results

The lxc is created properly.

Actual Results

no changes made:

TASK [Deploy container] ****************************************************************************************************************************************************************************************
task path: /workspaces/ansible/playbooks/temp.yml:5
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /tmp `"&& mkdir "` echo /tmp/ansible-tmp-1730048065.431875-12232-174057179046512 `" && echo ansible-tmp-1730048065.431875-12232-174057179046512="` echo /tmp/ansible-tmp-1730048065.431875-12232-174057179046512 `" ) && sleep 0'
Using module file /root/.ansible/collections/ansible_collections/community/general/plugins/modules/proxmox.py
<127.0.0.1> PUT /tmp/ansible-local-121447in0v0e5/tmp3c3vbqtv TO /tmp/ansible-tmp-1730048065.431875-12232-174057179046512/AnsiballZ_proxmox.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /tmp/ansible-tmp-1730048065.431875-12232-174057179046512/ /tmp/ansible-tmp-1730048065.431875-12232-174057179046512/AnsiballZ_proxmox.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python3 /tmp/ansible-tmp-1730048065.431875-12232-174057179046512/AnsiballZ_proxmox.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /tmp/ansible-tmp-1730048065.431875-12232-174057179046512/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
  File "/tmp/ansible_community.general.proxmox_payload_dfrkepn6/ansible_community.general.proxmox_payload.zip/ansible_collections/community/general/plugins/modules/proxmox.py", line 1181, in main
  File "/tmp/ansible_community.general.proxmox_payload_dfrkepn6/ansible_community.general.proxmox_payload.zip/ansible_collections/community/general/plugins/modules/proxmox.py", line 925, in create_instance
  File "/usr/local/lib/python3.11/dist-packages/proxmoxer/core.py", line 179, in create
    return self.post(*args, **data)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/proxmoxer/core.py", line 170, in post
    return self(args)._request("POST", data=data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/proxmoxer/core.py", line 147, in _request
    raise ResourceException(
fatal: [localhost]: FAILED! => changed=false 
  invocation:
    module_args:
      api_host: 10.1.3.10
      api_password: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
      api_port: null
      api_token_id: null
      api_token_secret: null
      api_user: root@pam
      clone: null
      clone_type: opportunistic
      cores: null
      cpus: null
      cpuunits: null
      description: null
      disk: null
      disk_volume:
        host_path: null
        options: null
        size: 8
        storage: INVALID
        volume: null
      features: null
      force: false
      hookscript: null
      hostname: test
      ip_address: null
      memory: null
      mount_volumes: null
      mounts: null
      nameserver: null
      netif: null
      node: pve1
      onboot: null
      ostemplate: templates:vztmpl/debian-12-standard_12.2-1_amd64.tar.zst
      ostype: auto
      password: null
      pool: null
      pubkey: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHZgvU6yP5kgEyEHfYrsBAod9lPJRtTbpl3EGQ/w7VZW aacater@net.retac.me
      purge: false
      searchdomain: null
      startup: null
      state: present
      storage: local
      swap: null
      tags: null
      timeout: 30
      timezone: null
      unprivileged: true
      update: false
      validate_certs: false
      vmid: 999
  msg: 'Creation of lxc VM 999 failed with exception: 400 Bad Request: Parameter verification failed. - {''disk_volume'': ''property is not defined in schema and the schema does not allow additional properties''}'
  vmid: 999

PLAY RECAP *****************************************************************************************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

if disk_volume is passed to proxmoxer as rootfs and storage is unset:

TASK [Deploy container] ****************************************************************************************************************************************************************************************
task path: /workspaces/ansible/playbooks/temp.yml:5
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /tmp `"&& mkdir "` echo /tmp/ansible-tmp-1730048338.5767107-12856-9893234748094 `" && echo ansible-tmp-1730048338.5767107-12856-9893234748094="` echo /tmp/ansible-tmp-1730048338.5767107-12856-9893234748094 `" ) && sleep 0'
Using module file /root/.ansible/collections/ansible_collections/community/general/plugins/modules/proxmox.py
<127.0.0.1> PUT /tmp/ansible-local-12768t2tikhaq/tmp_k3u3gdq TO /tmp/ansible-tmp-1730048338.5767107-12856-9893234748094/AnsiballZ_proxmox.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /tmp/ansible-tmp-1730048338.5767107-12856-9893234748094/ /tmp/ansible-tmp-1730048338.5767107-12856-9893234748094/AnsiballZ_proxmox.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python3 /tmp/ansible-tmp-1730048338.5767107-12856-9893234748094/AnsiballZ_proxmox.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /tmp/ansible-tmp-1730048338.5767107-12856-9893234748094/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
  File "/tmp/ansible_community.general.proxmox_payload_rbz6ee4o/ansible_community.general.proxmox_payload.zip/ansible_collections/community/general/plugins/modules/proxmox.py", line 1179, in main
  File "/tmp/ansible_community.general.proxmox_payload_rbz6ee4o/ansible_community.general.proxmox_payload.zip/ansible_collections/community/general/plugins/modules/proxmox.py", line 925, in create_instance
  File "/usr/local/lib/python3.11/dist-packages/proxmoxer/core.py", line 179, in create
    return self.post(*args, **data)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/proxmoxer/core.py", line 170, in post
    return self(args)._request("POST", data=data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/proxmoxer/core.py", line 147, in _request
    raise ResourceException(
fatal: [localhost]: FAILED! => changed=false 
  invocation:
    module_args:
      api_host: 10.1.3.10
      api_password: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
      api_port: null
      api_token_id: null
      api_token_secret: null
      api_user: root@pam
      clone: null
      clone_type: opportunistic
      cores: null
      cpus: null
      cpuunits: null
      description: null
      disk: null
      disk_volume:
        host_path: null
        options: null
        size: 8
        storage: INVALID
        volume: null
      features: null
      force: false
      hookscript: null
      hostname: test
      ip_address: null
      memory: null
      mount_volumes: null
      mounts: null
      nameserver: null
      netif: null
      node: pve1
      onboot: null
      ostemplate: templates:vztmpl/debian-12-standard_12.2-1_amd64.tar.zst
      ostype: auto
      password: null
      pool: null
      pubkey: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHZgvU6yP5kgEyEHfYrsBAod9lPJRtTbpl3EGQ/w7VZW aacater@net.retac.me
      purge: false
      searchdomain: null
      startup: null
      state: present
      storage: local
      swap: null
      tags: null
      timeout: 30
      timezone: null
      unprivileged: true
      update: false
      validate_certs: false
      vmid: 999
  msg: 'Creation of lxc VM 999 failed with exception: 500 Internal Server Error: storage ''local'' is disabled'
  vmid: 999

PLAY RECAP *****************************************************************************************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

if storage is made not mutually exclusive and then value changed:

TASK [Deploy container] ****************************************************************************************************************************************************************************************
task path: /workspaces/ansible/playbooks/temp.yml:5
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /tmp `"&& mkdir "` echo /tmp/ansible-tmp-1730048534.4794629-13206-101772407571122 `" && echo ansible-tmp-1730048534.4794629-13206-101772407571122="` echo /tmp/ansible-tmp-1730048534.4794629-13206-101772407571122 `" ) && sleep 0'
Using module file /root/.ansible/collections/ansible_collections/community/general/plugins/modules/proxmox.py
<127.0.0.1> PUT /tmp/ansible-local-13088bo0t4rlt/tmpfhfvx26d TO /tmp/ansible-tmp-1730048534.4794629-13206-101772407571122/AnsiballZ_proxmox.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /tmp/ansible-tmp-1730048534.4794629-13206-101772407571122/ /tmp/ansible-tmp-1730048534.4794629-13206-101772407571122/AnsiballZ_proxmox.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python3 /tmp/ansible-tmp-1730048534.4794629-13206-101772407571122/AnsiballZ_proxmox.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /tmp/ansible-tmp-1730048534.4794629-13206-101772407571122/ > /dev/null 2>&1 && sleep 0'
changed: [localhost] => changed=true 
  invocation:
    module_args:
      api_host: 10.1.3.10
      api_password: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
      api_port: null
      api_token_id: null
      api_token_secret: null
      api_user: root@pam
      clone: null
      clone_type: opportunistic
      cores: null
      cpus: null
      cpuunits: null
      description: null
      disk: null
      disk_volume:
        host_path: null
        options: null
        size: 8
        storage: INVALID
        volume: null
      features: null
      force: false
      hookscript: null
      hostname: test
      ip_address: null
      memory: null
      mount_volumes: null
      mounts: null
      nameserver: null
      netif: null
      node: pve1
      onboot: null
      ostemplate: templates:vztmpl/debian-12-standard_12.2-1_amd64.tar.zst
      ostype: auto
      password: null
      pool: null
      pubkey: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHZgvU6yP5kgEyEHfYrsBAod9lPJRtTbpl3EGQ/w7VZW aacater@net.retac.me
      purge: false
      searchdomain: null
      startup: null
      state: present
      storage: data-zfs
      swap: null
      tags: null
      timeout: 30
      timezone: null
      unprivileged: true
      update: false
      validate_certs: false
      vmid: 999
  msg: Deployed VM 999 from template templates:vztmpl/debian-12-standard_12.2-1_amd64.tar.zst
  vmid: 999

PLAY RECAP *****************************************************************************************************************************************************************************************************
localhost                  : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

the container is created successfully but the rootfs disk is only 4 GB.

Code of Conduct

  • I agree to follow the Ansible Code of Conduct

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions