Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ostype parameter in LXC container clone of Proxmox VE #7462

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- proxmox_ostype - it is now possible to specify the ``ostype`` when creating an LXC container (https://github.com/ansible-collections/community.general/pull/7462).
15 changes: 15 additions & 0 deletions plugins/modules/proxmox.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@
- target storage
type: str
default: 'local'
ostype:
description:
- Specifies the C(ostype) of the LXC container.
- If set to V(auto), no C(ostype) will be provided on instance creation.
choices: ['auto', 'debian', 'devuan', 'ubuntu', 'centos', 'fedora', 'opensuse', 'archlinux', 'alpine', 'gentoo', 'nixos', 'unmanaged']
type: str
default: 'auto'
felixfontein marked this conversation as resolved.
Show resolved Hide resolved
version_added: 8.1.0
cpuunits:
description:
- CPU weight for a VM
Expand Down Expand Up @@ -497,6 +505,9 @@ def create_instance(self, vmid, node, disk, storage, cpus, memory, swap, timeout
self.module.fail_json(msg='%s is not a valid tag' % tag)
kwargs['tags'] = ",".join(kwargs['tags'])

if kwargs.get('ostype') == 'auto':
kwargs.pop('ostype')

if clone is not None:
if VZ_TYPE != 'lxc':
self.module.fail_json(changed=False, msg="Clone operator is only supported for LXC enabled proxmox clusters.")
Expand Down Expand Up @@ -612,6 +623,9 @@ def main():
netif=dict(type='dict'),
mounts=dict(type='dict'),
ip_address=dict(),
ostype=dict(default='auto', choices=[
'auto', 'debian', 'devuan', 'ubuntu', 'centos', 'fedora', 'opensuse', 'archlinux', 'alpine', 'gentoo', 'nixos', 'unmanaged'
]),
onboot=dict(type='bool'),
features=dict(type='list', elements='str'),
storage=dict(default='local'),
Expand Down Expand Up @@ -719,6 +733,7 @@ def main():
ostemplate=module.params['ostemplate'],
netif=module.params['netif'],
mounts=module.params['mounts'],
ostype=module.params['ostype'],
ip_address=module.params['ip_address'],
onboot=ansible_to_proxmox_bool(module.params['onboot']),
cpuunits=module.params['cpuunits'],
Expand Down