From 2583c60487e48305d3400df80b29533c3b18bc7e Mon Sep 17 00:00:00 2001 From: blacknon Date: Sat, 11 Nov 2023 20:02:53 +0900 Subject: [PATCH] Add ostype parameter in LXC container clone of Proxmox VE (#7462) * update. proxmox lxc add ostype param * update. * update. E501 * update. E123 * update. pullrequestreview-1711205075 * update. commit undo formatted by editor auto-update * update. add change fragment (pullrequestreview-1711205075) * update. pullrequestreview-1711911827 --- ...meter-in-LXC-container-clone-of-ProxmoxVE.yaml | 2 ++ plugins/modules/proxmox.py | 15 +++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 changelogs/fragments/7462-Add-ostype-parameter-in-LXC-container-clone-of-ProxmoxVE.yaml diff --git a/changelogs/fragments/7462-Add-ostype-parameter-in-LXC-container-clone-of-ProxmoxVE.yaml b/changelogs/fragments/7462-Add-ostype-parameter-in-LXC-container-clone-of-ProxmoxVE.yaml new file mode 100644 index 0000000000..20a9b1d144 --- /dev/null +++ b/changelogs/fragments/7462-Add-ostype-parameter-in-LXC-container-clone-of-ProxmoxVE.yaml @@ -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). diff --git a/plugins/modules/proxmox.py b/plugins/modules/proxmox.py index 7f84a30fcd..b9afd379e1 100644 --- a/plugins/modules/proxmox.py +++ b/plugins/modules/proxmox.py @@ -98,6 +98,14 @@ options: - 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' + version_added: 8.1.0 cpuunits: description: - CPU weight for a VM @@ -515,6 +523,9 @@ class ProxmoxLxcAnsible(ProxmoxAnsible): 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.") @@ -637,6 +648,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'), @@ -744,6 +758,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'],