Repository: ansible-collections/community.general

Issue:
proxmox: Lack of error checking: "Cloning lxc VM 100 failed with exception: 'template'"
### Summary

Cloning fails with cryptic arrors. Actually at a lof of places, some due to proxmoxer but some not. This is one of such places.

I am not sure what the original idea was, but this lacks error checking whatever it was:
```diff
--- /usr/lib/python3/dist-packages/ansible_collections/community/general/plugins/modules/cloud/misc/proxmox.py~ 2022-10-15 16:33:33.000000000 +0200
+++ /usr/lib/python3/dist-packages/ansible_collections/community/general/plugins/modules/cloud/misc/proxmox.py  2022-10-15 16:37:44.390779428 +0200
@@ -412,7 +412,9 @@
         """Check if the specified container is a template."""
         proxmox_node = self.proxmox_api.nodes(node)
         config = getattr(proxmox_node, VZ_TYPE)(vmid).config.get()
+        if 'template' in config:
+            return config['template']
+        return False
-         return config['template']
 
     def create_instance(self, vmid, node, disk, storage, cpus, memory, swap, timeout, clone, **kwargs):
```
Chokes when config doesn't contain "template". I left to the reader to determine when this happens.


### Issue Type

Bug Report

### Component Name

/usr/lib/python3/dist-packages/ansible_collections/community/general/plugins/modules/cloud/misc/proxmox.py

### Ansible Version

ansible [core 2.13.4]


### Community.general Version

community.general 5.6.0  


### Configuration

_No response_

### OS / Environment

_No response_

### Steps to Reproduce

configure/clone various PVE versions, observe some of the fail.

### Expected Results

1. error checking
2. non-cryptic error messages (both API HTTP and data responses)


### Actual Results

Haphazard results and lot of guesswork at configs.

### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct


Discussion:
Files identified in the description:
* [`plugins/modules/cloud/misc/proxmox.py`](https://github.com/ansible-collections/community.general/blob/main/plugins/modules/cloud/misc/proxmox.py)

If these files are incorrect, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/devel/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
cc @Ajpantuso @Thulium-Drake @UnderGreen @joshainglis @karmab @tleguern
[click here for bot help](https://github.com/ansible/ansibullbot/blob/devel/ISSUE_HELP.md)
<!--- boilerplate: notify --->
Files identified in the description:
* [`plugins/modules/proxmox.py`](https://github.com/ansible-collections/community.general/blob/main/plugins/modules/proxmox.py)

If these files are incorrect, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/devel/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->

Resolving patch:
diff --git a/plugins/modules/proxmox.py b/plugins/modules/proxmox.py
--- a/plugins/modules/proxmox.py
+++ b/plugins/modules/proxmox.py
@@ -448,7 +448,7 @@ def is_template_container(self, node, vmid):
         """Check if the specified container is a template."""
         proxmox_node = self.proxmox_api.nodes(node)
         config = getattr(proxmox_node, VZ_TYPE)(vmid).config.get()
-        return config['template']
+        return config.get('template', False)
 
     def create_instance(self, vmid, node, disk, storage, cpus, memory, swap, timeout, clone, **kwargs):
 


Test patch: