Skip to content

Commit

Permalink
[PR #9645/37a9413a backport][stable-10] proxmox: fix pubkey translati…
Browse files Browse the repository at this point in the history
…on and usage in update (#9648)

proxmox: fix pubkey translation and usage in update (#9645)

* proxmox: fix: pubkey translation and usage in update

* proxmox fix: add changelog

* proxmox: fix backticks in changelog

(cherry picked from commit 37a9413)

Co-authored-by: JL Euler <[email protected]>
  • Loading branch information
patchback[bot] and Lithimlin authored Jan 29, 2025
1 parent 0331798 commit 163bfd0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions changelogs/fragments/9645-proxmox-fix-pubkey.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bugfixes:
- proxmox - fixes a typo in the translation of the ``pubkey`` parameter to proxmox' ``ssh-public-keys`` (https://github.com/ansible-collections/community.general/issues/9642, https://github.com/ansible-collections/community.general/pull/9645).
- proxmox - adds the ``pubkey`` parameter (back to) the ``update`` state (https://github.com/ansible-collections/community.general/issues/9642, https://github.com/ansible-collections/community.general/pull/9645).
11 changes: 10 additions & 1 deletion plugins/modules/proxmox.py
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,15 @@ def update_lxc_instance(self, vmid, node, **kwargs):
if "netif" in kwargs:
kwargs.update(kwargs.pop("netif"))

if "pubkey" in kwargs:
pubkey = kwargs.pop("pubkey")
if self.version() >= LooseVersion("4.2"):
kwargs["ssh-public-keys"] = pubkey
else:
self.module.warn(
"'pubkey' is not supported for PVE 4.1 and below. Ignoring keyword."
)

# fetch current config
proxmox_node = self.proxmox_api.nodes(node)
current_config = getattr(proxmox_node, self.VZ_TYPE)(vmid).config.get()
Expand Down Expand Up @@ -1215,7 +1224,7 @@ def create_lxc_instance(self, vmid, node, ostemplate, timeout, **kwargs):
if "pubkey" in kwargs:
pubkey = kwargs.pop("pubkey")
if self.version() >= LooseVersion("4.2"):
kwargs["ssh-public-key"] = pubkey
kwargs["ssh-public-keys"] = pubkey
else:
self.module.warn(
"'pubkey' is not supported for PVE 4.1 and below. Ignoring keyword."
Expand Down

0 comments on commit 163bfd0

Please sign in to comment.