From 1f6d404debe6896d64d629f03af9af81f370e05e Mon Sep 17 00:00:00 2001
From: Paul Levytskyi <25350788+levytskyip@users.noreply.github.com>
Date: Mon, 12 Jun 2023 15:44:26 -0400
Subject: [PATCH] Proxmox inventory plugin: support composite variables (#6641)

* Added composite var support for proxmox inventory plugin

* Composite variables support for Proxmox nodes in dynamic inventory plugin
Fixes #6640

* Composite variables support for Proxmox nodes in dynamic inventory plugin
Fixes #6640

* Added composite var support for proxmox inventory plugin

* Added composite var support for proxmox inventory plugin

* Update changelogs/fragments/6640-proxmox-composite-variables-support.yml

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

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
---
 .../fragments/6640-proxmox-composite-variables-support.yml    | 3 +++
 plugins/inventory/proxmox.py                                  | 4 ++++
 2 files changed, 7 insertions(+)
 create mode 100644 changelogs/fragments/6640-proxmox-composite-variables-support.yml

diff --git a/changelogs/fragments/6640-proxmox-composite-variables-support.yml b/changelogs/fragments/6640-proxmox-composite-variables-support.yml
new file mode 100644
index 0000000000..bce33c01ba
--- /dev/null
+++ b/changelogs/fragments/6640-proxmox-composite-variables-support.yml
@@ -0,0 +1,3 @@
+---
+minor_changes:
+  - proxmox inventory plugin - add composite variables support for Proxmox nodes (https://github.com/ansible-collections/community.general/issues/6640).
diff --git a/plugins/inventory/proxmox.py b/plugins/inventory/proxmox.py
index 1389f9ee26..d0053afbd7 100644
--- a/plugins/inventory/proxmox.py
+++ b/plugins/inventory/proxmox.py
@@ -590,6 +590,10 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
                 ip = self._get_node_ip(node['node'])
                 self.inventory.set_variable(node['node'], 'ansible_host', ip)
 
+            # Setting composite variables
+            variables = self.inventory.get_host(node['node']).get_vars()
+            self._set_composite_vars(self.get_option('compose'), variables, node['node'], strict=self.strict)
+
             # add LXC/Qemu groups for the node
             for ittype in ('lxc', 'qemu'):
                 node_type_group = self._group('%s_%s' % (node['node'], ittype))