Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix new Proxmox Volume handling #8646

Merged
merged 7 commits into from
Jul 23, 2024

Conversation

Lithimlin
Copy link
Contributor

SUMMARY

This fixes two issues with the new proxmox volume handling (disk_volume and mount_volumes):

  1. In the plugin, a string conversion was previously forced that clashed with the documentation and incorrectly converted None-type values into "None" strings.
  2. In the build_volume() method of the plugin, half of the built string was accidentally discarded.
ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

proxmox

ADDITIONAL INFORMATION

Here is a sample playbook to test the validity:

---
- name: Create LXC
  hosts: localhost
  become: false
  gather_facts: false
  vars_files:
    - proxmox_credentials.yml
  tasks:
    - name: Create LXC
      community.general.proxmox:
        api_host: "{{ api_host }}"
        api_user: "{{ api_user }}"
        api_password: "{{ api_password }}"
        # api_token_id: "{{ api_token_id }}"
        # api_token_secret: "{{ api_token_secret }}"
        node: "{{ node }}"
        hostname: test-node
        ostemplate: local:vztmpl/debian-12-standard_12.2-1_amd64.tar.zst
        disk: local-lvm:8
      register: create_res

    - name: Update LXC config [new - create volumes]
      community.general.proxmox:
        api_host: "{{ api_host }}"
        api_user: "{{ api_user }}"
        api_password: "{{ api_password }}"
        # api_token_id: "{{ api_token_id }}"
        # api_token_secret: "{{ api_token_secret }}"
        node: "{{ node }}"
        hostname: test-node
        cores: 1
        vmid: "{{ create_res.vmid }}"
        disk_volume:
          storage: local-lvm
          size: 14
        mount_volumes:
          - id: mp0
            storage: local-lvm
            size: 3
            mountpoint: /mnt/test
          - id: mp1
            host_path: /root/test
            mountpoint: /mnt/host
            options:
              backup: "0"
        update: true

    - name: Update LXC config [new - explicit volumes]
      community.general.proxmox:
        api_host: "{{ api_host }}"
        api_user: "{{ api_user }}"
        api_password: "{{ api_password }}"
        # api_token_id: "{{ api_token_id }}"
        # api_token_secret: "{{ api_token_secret }}"
        node: "{{ node }}"
        hostname: test-node
        cores: 1
        vmid: "{{ create_res.vmid }}"
        disk_volume:
          storage: local-lvm
          volume: "vm-{{ create_res.vmid }}-disk-0"
          size: 14
        mount_volumes:
          - id: mp0
            storage: local-lvm
            volume: "vm-{{ create_res.vmid }}-disk-1"
            size: 3
            mountpoint: /mnt/test
          - id: mp1
            host_path: /root/test
            mountpoint: /mnt/host
            options:
              backup: "0"
        update: true

    - name: Update LXC config [old - implicit volumes]
      community.general.proxmox:
        api_host: "{{ api_host }}"
        api_user: "{{ api_user }}"
        api_password: "{{ api_password }}"
        # api_token_id: "{{ api_token_id }}"
        # api_token_secret: "{{ api_token_secret }}"
        node: "{{ node }}"
        hostname: test-node
        cores: 1
        vmid: "{{ create_res.vmid }}"
        disk: local-lvm:14
        mounts: '{"mp0":"local-lvm:3,mp=/mnt/test","mp1":"/root/test,mp=/mnt/host,backup=0"}'
        update: true

    - name: Update LXC config [old - explicit volumes]
      community.general.proxmox:
        api_host: "{{ api_host }}"
        api_user: "{{ api_user }}"
        api_password: "{{ api_password }}"
        # api_token_id: "{{ api_token_id }}"
        # api_token_secret: "{{ api_token_secret }}"
        node: "{{ node }}"
        hostname: test-node
        cores: 1
        vmid: "{{ create_res.vmid }}"
        disk: "local-lvm:vm-{{ create_res.vmid }}-disk-0,size=14G"
        mounts: '{"mp0":"local-lvm:vm-{{ create_res.vmid }}-disk-1,size=3G,mp=/mnt/test","mp1":"/root/test,mp=/mnt/host,backup=0"}'
        update: true

Half of the string was incorrectly discarded
 - Also converted `None` values into strings
 - Clashed with non-`str` values in documentation
@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added bug This issue/PR relates to a bug module module plugins plugin (any type) labels Jul 16, 2024
@felixfontein felixfontein added check-before-release PR will be looked at again shortly before release and merged if possible. backport-9 Automatically create a backport for the stable-9 branch labels Jul 16, 2024
Copy link
Collaborator

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this fix!

changelogs/fragments/8646-fix-bug-in-proxmox-volumes.yml Outdated Show resolved Hide resolved
plugins/modules/proxmox.py Outdated Show resolved Hide resolved
Lithimlin and others added 2 commits July 23, 2024 16:27
Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Felix Fontein <felix@fontein.de>
@ansibullbot ansibullbot added needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR and removed needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Jul 23, 2024
@felixfontein felixfontein merged commit e1148e6 into ansible-collections:main Jul 23, 2024
147 checks passed
Copy link

patchback bot commented Jul 23, 2024

Backport to stable-9: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-9/e1148e6bdcaa0bf5c0135197fb774af9f7f06cb4/pr-8646

Backported as #8667

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Jul 23, 2024
* proxmox(fix): volume string builder

Half of the string was incorrectly discarded

* proxmox(fix): remove string conversion of values

 - Also converted `None` values into strings
 - Clashed with non-`str` values in documentation

* proxmox: add changelog fragment

* proxmox(fix): remove old & unused imports

* proxmox(fix): correctly turn maps into lists

* Update changelogs/fragments/8646-fix-bug-in-proxmox-volumes.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/modules/proxmox.py

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit e1148e6)
@felixfontein felixfontein removed the check-before-release PR will be looked at again shortly before release and merged if possible. label Jul 23, 2024
@felixfontein
Copy link
Collaborator

@Lithimlin thanks for your contribution!

felixfontein pushed a commit that referenced this pull request Jul 23, 2024
#8667)

Fix new Proxmox Volume handling (#8646)

* proxmox(fix): volume string builder

Half of the string was incorrectly discarded

* proxmox(fix): remove string conversion of values

 - Also converted `None` values into strings
 - Clashed with non-`str` values in documentation

* proxmox: add changelog fragment

* proxmox(fix): remove old & unused imports

* proxmox(fix): correctly turn maps into lists

* Update changelogs/fragments/8646-fix-bug-in-proxmox-volumes.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/modules/proxmox.py

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit e1148e6)

Co-authored-by: JL Euler <Lithimlin@users.noreply.github.com>
Acarnesecchi added a commit to Acarnesecchi/community.general that referenced this pull request Jul 25, 2024
fixed group logic. Removed trailing spaces

Type options of become plugins (ansible-collections#8623)

Type options of become plugins.

Type options of lookup plugins (ansible-collections#8626)

Type options of lookup plugins.

Type options of inventory plugins (ansible-collections#8625)

Type options of inventory plugins.

Type options of connection plugins (ansible-collections#8627)

Type options of connection plugins.

Type options of callback plugins (ansible-collections#8628)

Type options of callback plugins.

Various docs improvements (ansible-collections#8664)

Various docs improvements.

Fix new Proxmox Volume handling (ansible-collections#8646)

* proxmox(fix): volume string builder

Half of the string was incorrectly discarded

* proxmox(fix): remove string conversion of values

 - Also converted `None` values into strings
 - Clashed with non-`str` values in documentation

* proxmox: add changelog fragment

* proxmox(fix): remove old & unused imports

* proxmox(fix): correctly turn maps into lists

* Update changelogs/fragments/8646-fix-bug-in-proxmox-volumes.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/modules/proxmox.py

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>

pkgng - add option use_globs (default=true) (ansible-collections#8633)

* pkgng - add option use_globs (default=true) ansible-collections#8632

* Fix lint.

* Update changelogs/fragments/8632-pkgng-add-option-use_globs.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/modules/pkgng.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/modules/pkgng.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update tests/integration/targets/pkgng/tasks/install_single_package.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/modules/pkgng.py

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>

Fix pipx tests (ansible-collections#8665)

* fix pipx tests

* enable pipx int tests

* replace ansible-lint with pylint in pipx test

* install jupyter in freebsd

* replace jupyter with mkdocs in pipx test

* adjust installed dependency for mkdocs

* fix pipx_info tests as well

Add TLS certs params to redis (ansible-collections#8654)

* add tls params to redis

* add PR number

* add example

* move doc to redis fragment

* Update changelogs/fragments/8654-add-redis-tls-params.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* rm aliases and add version_added

---------

Co-authored-by: Felix Fontein <felix@fontein.de>

fixed pep8 errors

changed group_access_level description as "not required"
Acarnesecchi added a commit to Acarnesecchi/community.general that referenced this pull request Jul 25, 2024
fixed group logic. Removed trailing spaces

Type options of become plugins (ansible-collections#8623)

Type options of become plugins.

Type options of lookup plugins (ansible-collections#8626)

Type options of lookup plugins.

Type options of inventory plugins (ansible-collections#8625)

Type options of inventory plugins.

Type options of connection plugins (ansible-collections#8627)

Type options of connection plugins.

Type options of callback plugins (ansible-collections#8628)

Type options of callback plugins.

Various docs improvements (ansible-collections#8664)

Various docs improvements.

Fix new Proxmox Volume handling (ansible-collections#8646)

* proxmox(fix): volume string builder

Half of the string was incorrectly discarded

* proxmox(fix): remove string conversion of values

 - Also converted `None` values into strings
 - Clashed with non-`str` values in documentation

* proxmox: add changelog fragment

* proxmox(fix): remove old & unused imports

* proxmox(fix): correctly turn maps into lists

* Update changelogs/fragments/8646-fix-bug-in-proxmox-volumes.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/modules/proxmox.py

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>

pkgng - add option use_globs (default=true) (ansible-collections#8633)

* pkgng - add option use_globs (default=true) ansible-collections#8632

* Fix lint.

* Update changelogs/fragments/8632-pkgng-add-option-use_globs.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/modules/pkgng.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/modules/pkgng.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update tests/integration/targets/pkgng/tasks/install_single_package.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/modules/pkgng.py

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>

Fix pipx tests (ansible-collections#8665)

* fix pipx tests

* enable pipx int tests

* replace ansible-lint with pylint in pipx test

* install jupyter in freebsd

* replace jupyter with mkdocs in pipx test

* adjust installed dependency for mkdocs

* fix pipx_info tests as well

Add TLS certs params to redis (ansible-collections#8654)

* add tls params to redis

* add PR number

* add example

* move doc to redis fragment

* Update changelogs/fragments/8654-add-redis-tls-params.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* rm aliases and add version_added

---------

Co-authored-by: Felix Fontein <felix@fontein.de>

fixed pep8 errors

changed group_access_level description as "not required"

fix required
Acarnesecchi added a commit to Acarnesecchi/community.general that referenced this pull request Jul 25, 2024
fixed group logic. Removed trailing spaces

Type options of become plugins (ansible-collections#8623)

Type options of become plugins.

Type options of lookup plugins (ansible-collections#8626)

Type options of lookup plugins.

Type options of inventory plugins (ansible-collections#8625)

Type options of inventory plugins.

Type options of connection plugins (ansible-collections#8627)

Type options of connection plugins.

Type options of callback plugins (ansible-collections#8628)

Type options of callback plugins.

Various docs improvements (ansible-collections#8664)

Various docs improvements.

Fix new Proxmox Volume handling (ansible-collections#8646)

* proxmox(fix): volume string builder

Half of the string was incorrectly discarded

* proxmox(fix): remove string conversion of values

 - Also converted `None` values into strings
 - Clashed with non-`str` values in documentation

* proxmox: add changelog fragment

* proxmox(fix): remove old & unused imports

* proxmox(fix): correctly turn maps into lists

* Update changelogs/fragments/8646-fix-bug-in-proxmox-volumes.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/modules/proxmox.py

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>

pkgng - add option use_globs (default=true) (ansible-collections#8633)

* pkgng - add option use_globs (default=true) ansible-collections#8632

* Fix lint.

* Update changelogs/fragments/8632-pkgng-add-option-use_globs.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/modules/pkgng.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/modules/pkgng.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update tests/integration/targets/pkgng/tasks/install_single_package.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/modules/pkgng.py

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>

Fix pipx tests (ansible-collections#8665)

* fix pipx tests

* enable pipx int tests

* replace ansible-lint with pylint in pipx test

* install jupyter in freebsd

* replace jupyter with mkdocs in pipx test

* adjust installed dependency for mkdocs

* fix pipx_info tests as well

Add TLS certs params to redis (ansible-collections#8654)

* add tls params to redis

* add PR number

* add example

* move doc to redis fragment

* Update changelogs/fragments/8654-add-redis-tls-params.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* rm aliases and add version_added

---------

Co-authored-by: Felix Fontein <felix@fontein.de>

fixed pep8 errors

changed group_access_level description as "not required"

fix required

fix
aioue pushed a commit to aioue/community.general that referenced this pull request Oct 1, 2024
* proxmox(fix): volume string builder

Half of the string was incorrectly discarded

* proxmox(fix): remove string conversion of values

 - Also converted `None` values into strings
 - Clashed with non-`str` values in documentation

* proxmox: add changelog fragment

* proxmox(fix): remove old & unused imports

* proxmox(fix): correctly turn maps into lists

* Update changelogs/fragments/8646-fix-bug-in-proxmox-volumes.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/modules/proxmox.py

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
TobiasZeuch181 pushed a commit to TobiasZeuch181/zypper_repository_add_list that referenced this pull request Oct 2, 2024
* proxmox(fix): volume string builder

Half of the string was incorrectly discarded

* proxmox(fix): remove string conversion of values

 - Also converted `None` values into strings
 - Clashed with non-`str` values in documentation

* proxmox: add changelog fragment

* proxmox(fix): remove old & unused imports

* proxmox(fix): correctly turn maps into lists

* Update changelogs/fragments/8646-fix-bug-in-proxmox-volumes.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/modules/proxmox.py

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
Massl123 pushed a commit to Massl123/community.general that referenced this pull request Feb 7, 2025
* proxmox(fix): volume string builder

Half of the string was incorrectly discarded

* proxmox(fix): remove string conversion of values

 - Also converted `None` values into strings
 - Clashed with non-`str` values in documentation

* proxmox: add changelog fragment

* proxmox(fix): remove old & unused imports

* proxmox(fix): correctly turn maps into lists

* Update changelogs/fragments/8646-fix-bug-in-proxmox-volumes.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/modules/proxmox.py

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-9 Automatically create a backport for the stable-9 branch bug This issue/PR relates to a bug module module plugins plugin (any type)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants