mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-26 22:51:23 -07:00
* fix #19487 * add 'version_added' * Check for version compatibility, Ignore keys if incompatible * add comment about version support * remove 'type' as requested * fix merge error
This commit is contained in:
parent
829f3bd019
commit
b5811ccb8a
1 changed files with 17 additions and 1 deletions
|
@ -175,6 +175,13 @@ options:
|
||||||
- Indicate desired state of the instance
|
- Indicate desired state of the instance
|
||||||
choices: ['present', 'started', 'absent', 'stopped', 'restarted']
|
choices: ['present', 'started', 'absent', 'stopped', 'restarted']
|
||||||
default: present
|
default: present
|
||||||
|
pubkey:
|
||||||
|
description:
|
||||||
|
- Public key to add to /root/.ssh/authorized_keys. This was added on Proxmox 4.2, it is ignored for earlier versions
|
||||||
|
version_added: "2.3"
|
||||||
|
default: null
|
||||||
|
required: false
|
||||||
|
|
||||||
notes:
|
notes:
|
||||||
- Requires proxmoxer and requests modules on host. This modules can be installed with pip.
|
- Requires proxmoxer and requests modules on host. This modules can be installed with pip.
|
||||||
requirements: [ "proxmoxer", "python >= 2.7", "requests" ]
|
requirements: [ "proxmoxer", "python >= 2.7", "requests" ]
|
||||||
|
@ -329,6 +336,7 @@ def node_check(proxmox, node):
|
||||||
def create_instance(module, proxmox, vmid, node, disk, storage, cpus, memory, swap, timeout, **kwargs):
|
def create_instance(module, proxmox, vmid, node, disk, storage, cpus, memory, swap, timeout, **kwargs):
|
||||||
proxmox_node = proxmox.nodes(node)
|
proxmox_node = proxmox.nodes(node)
|
||||||
kwargs = dict((k,v) for k, v in kwargs.items() if v is not None)
|
kwargs = dict((k,v) for k, v in kwargs.items() if v is not None)
|
||||||
|
|
||||||
if VZ_TYPE =='lxc':
|
if VZ_TYPE =='lxc':
|
||||||
kwargs['cpulimit']=cpus
|
kwargs['cpulimit']=cpus
|
||||||
kwargs['rootfs']=disk
|
kwargs['rootfs']=disk
|
||||||
|
@ -338,9 +346,14 @@ def create_instance(module, proxmox, vmid, node, disk, storage, cpus, memory, sw
|
||||||
if 'mounts' in kwargs:
|
if 'mounts' in kwargs:
|
||||||
kwargs.update(kwargs['mounts'])
|
kwargs.update(kwargs['mounts'])
|
||||||
del kwargs['mounts']
|
del kwargs['mounts']
|
||||||
|
if 'pubkey' in kwargs:
|
||||||
|
if float(proxmox.version.get()['version']) >= 4.2:
|
||||||
|
kwargs['ssh-public-keys'] = kwargs['pubkey']
|
||||||
|
del kwargs['pubkey']
|
||||||
else:
|
else:
|
||||||
kwargs['cpus']=cpus
|
kwargs['cpus']=cpus
|
||||||
kwargs['disk']=disk
|
kwargs['disk']=disk
|
||||||
|
|
||||||
taskid = getattr(proxmox_node, VZ_TYPE).create(vmid=vmid, storage=storage, memory=memory, swap=swap, **kwargs)
|
taskid = getattr(proxmox_node, VZ_TYPE).create(vmid=vmid, storage=storage, memory=memory, swap=swap, **kwargs)
|
||||||
|
|
||||||
while timeout:
|
while timeout:
|
||||||
|
@ -428,6 +441,7 @@ def main():
|
||||||
timeout = dict(type='int', default=30),
|
timeout = dict(type='int', default=30),
|
||||||
force = dict(type='bool', default='no'),
|
force = dict(type='bool', default='no'),
|
||||||
state = dict(default='present', choices=['present', 'absent', 'stopped', 'started', 'restarted']),
|
state = dict(default='present', choices=['present', 'absent', 'stopped', 'started', 'restarted']),
|
||||||
|
pubkey = dict(type='str', default=None)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -502,7 +516,9 @@ def main():
|
||||||
cpuunits = module.params['cpuunits'],
|
cpuunits = module.params['cpuunits'],
|
||||||
nameserver = module.params['nameserver'],
|
nameserver = module.params['nameserver'],
|
||||||
searchdomain = module.params['searchdomain'],
|
searchdomain = module.params['searchdomain'],
|
||||||
force = int(module.params['force']))
|
force = int(module.params['force']),
|
||||||
|
pubkey = module.params['pubkey']
|
||||||
|
)
|
||||||
|
|
||||||
module.exit_json(changed=True, msg="deployed VM %s from template %s" % (vmid, module.params['ostemplate']))
|
module.exit_json(changed=True, msg="deployed VM %s from template %s" % (vmid, module.params['ostemplate']))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue