Skip to content

Commit

Permalink
Change Proxmox agent argument to string.
Browse files Browse the repository at this point in the history
  • Loading branch information
reitermarkus committed Aug 11, 2022
1 parent dc17044 commit 64ea88c
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions plugins/modules/cloud/misc/proxmox_kvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
agent:
description:
- Specify if the QEMU Guest Agent should be enabled/disabled.
type: bool
- Since community.general 5.5.0, this can also be a string instead of a boolean.
This allows to specify values such as C(enabled=1,fstrim_cloned_disks=1).
type: str
args:
description:
- Pass arbitrary arguments to kvm.
Expand Down Expand Up @@ -809,6 +811,7 @@

from ansible.module_utils.basic import AnsibleModule, missing_required_lib
from ansible.module_utils.common.text.converters import to_native
from ansible.module_utils.parsing.convert_bool import boolean


def parse_mac(netstr):
Expand Down Expand Up @@ -960,7 +963,17 @@ def create_vm(self, vmid, newid, node, name, memory, cpu, cores, sockets, update
kwargs.update(kwargs[k])
del kwargs[k]

# Rename numa_enabled to numa. According the API documentation
# Map bool to string, according to API documentation.
try:
if boolean(kwargs['agent'], strict=True):
kwargs['agent'] = 'enabled=1'
else:
kwargs['agent'] = 'enabled=0'
except TypeError:
# Not something that Ansible would parse as a boolean.
pass

# Rename numa_enabled to numa, according the API documentation
if 'numa_enabled' in kwargs:
kwargs['numa'] = kwargs['numa_enabled']
del kwargs['numa_enabled']
Expand Down Expand Up @@ -1040,7 +1053,7 @@ def main():
module_args = proxmox_auth_argument_spec()
kvm_args = dict(
acpi=dict(type='bool'),
agent=dict(type='bool'),
agent=dict(type='str'),
args=dict(type='str'),
autostart=dict(type='bool'),
balloon=dict(type='int'),
Expand Down

0 comments on commit 64ea88c

Please sign in to comment.