Skip to content

Proxmox LXC - Mounts configuration causes repeated creation of volumes #8407

Closed
@Lithimlin

Description

Summary

Currently, it seems the creation of mount points with the documented syntax is not idempotent but instead creates a new mount disk each time the update task is run.

In the documentation's example, the syntax is:
<storage>:<size-in-GB>,mp=<mountpoint>

Issue Type

Bug Report

Component Name

proxmox

Ansible Version

$ ansible --version
ansible [core 2.16.7]
  config file = <my-repo>/ansible.cfg
  configured module search path = ['<my-home>/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = <my-repo>/.venv/lib/python3.12/site-packages/ansible
  ansible collection location = <my-home>/.ansible/collections:/usr/share/ansible/collections
  executable location = <my-repo>/.venv/bin/ansible
  python version = 3.12.3 (main, Apr 23 2024, 09:16:07) [GCC 13.2.1 20240417] (<my-repo>/.venv/bin/python)
  jinja version = 3.1.4
  libyaml = True

Community.general Version

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

Configuration

$ ansible-config dump --only-changed
CONFIG_FILE() = <my-repo>/ansible.cfg
DEFAULT_ROLES_PATH(<my-repo>/ansible.cfg) = ['<my-repo>/roles']
DEFAULT_TIMEOUT(<my-repo>/ansible.cfg) = 30
EDITOR(env: EDITOR) = vim
PAGER(env: PAGER) = less

OS / Environment

proxmoxer==2.0.1
requests==2.32.2

Steps to Reproduce

- name: Create LXC
  community.general.proxmox:
    api_host: "{{ api_host }}"
    api_user: "{{ api_user }}"
    api_token_id: "{{ api_token_id }}"
    api_token_secret: "{{ api_token_secret }}"
    hostname: "{{ inventory_hostname }}"
    node: my-node
    ostemplate: images:vztmpl/debian-12-standard_12.2-1_amd64.tar.zst
    storage: machines01
    timeout: 30
  register: create_result

- name: Update LXC config
  community.general.proxmox:
    api_host: "{{ api_host }}"
    api_user: "{{ api_user }}"
    api_token_id: "{{ api_token_id }}"
    api_token_secret: "{{ api_token_secret }}"
    node: my-node
    vmid: "{{ create_result.vmid }}"
    cores: 2
    memory: 2048
    swap: 2048
    disk: machines01:vm-{{ create_result.vmid }}-disk-0,size=12G"
    mounts: 
      mp0: machines01:4,mp=/mnt/data
    update: true

Expected Results

The LXC is created and configured with a single mountpoint idempotently, even when the playbook is run again.
More importantly, no extra volumes are created on subsequent runs unless specified.

Actual Results

The LXC is updated and a new mount volume is created. On a container restart, the previous volume is unmounted and the newly-created on is mounted.
In the machines01 storage, new volumes vm-<id>-disk-<n> are created each time the playbook is run.
In the LXC resources tab, the actually mounted disk is machines01:vm-<id>-disk-<n>,mp=/mnt/data,size=4G with a change to machines01:4,mp=/mnt/data is queued.

Code of Conduct

  • I agree to follow the Ansible Code of Conduct

Metadata

Assignees

No one assigned

    Labels

    bugThis issue/PR relates to a bugmodulemodulepluginsplugin (any type)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions