community.general.proxmox module – Management of instances in Proxmox VE cluster
Note
This module is part of the community.general collection (version 6.6.2).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.general
.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: community.general.proxmox
.
Synopsis
allows you to create/delete/stop instances in Proxmox VE cluster
Starting in Ansible 2.1, it automatically detects containerization type (lxc for PVE 4, openvz for older)
Since community.general 4.0.0 on, there are no more default values, see proxmox_default_behavior.
Requirements
The below requirements are needed on the host that executes this module.
proxmoxer
requests
Parameters
Parameter |
Comments |
---|---|
Specify the target host of the Proxmox VE cluster. |
|
Specify the password to authenticate with. You can use |
|
Specify the token ID. |
|
Specify the token secret. |
|
Specify the user to authenticate with. |
|
ID of the container to be cloned. description, hostname, and pool will be copied from the cloned container if not specified. The type of clone created is defined by the clone_type parameter. This operator is only supported for Proxmox clusters that use LXC containerization (PVE version >= 4). |
|
Type of the clone created.
Choices:
|
|
Specify number of cores per socket. This option has no default unless proxmox_default_behavior is set to |
|
numbers of allocated cpus for instance This option has no default unless proxmox_default_behavior is set to |
|
CPU weight for a VM This option has no default unless proxmox_default_behavior is set to |
|
Specify the description for the container. Only used on the configuration web interface. This is saved as a comment inside the configuration file. |
|
This option was previously described as “hard disk size in GB for instance” however several formats describing a lxc mount are permitted. Older versions of Proxmox will accept a numeric value for size using the storage parameter to automatically choose which storage to allocate from, however new versions enforce the Additional options are available by using some combination of the following key-value pairs as a comma-delimited list See https://pve.proxmox.com/wiki/Linux_Container for a full description. This option has no default unless proxmox_default_behavior is set to |
|
Specifies a list of features to be enabled. For valid options, see https://pve.proxmox.com/wiki/Linux_Container#pct_options. Some features require the use of a privileged container. |
|
forcing operations can be used only with states with with states Choices:
|
|
Script that will be executed during various steps in the containers lifetime. |
|
the instance hostname required only for must be unique if vmid is not passed |
|
specifies the address the container will be assigned |
|
memory size in MB for instance This option has no default unless proxmox_default_behavior is set to |
|
specifies additional mounts (separate disks) for the container. As a hash/dictionary defining mount points |
|
sets DNS server IP address for a container |
|
specifies network interfaces for the container. As a hash/dictionary defining interfaces. |
|
Proxmox VE node on which to operate. Only required for state=present. For every other states it will be autodiscovered. |
|
specifies whether a VM will be started during system bootup This option has no default unless proxmox_default_behavior is set to Choices:
|
|
the template for VM creating required only for |
|
the instance root password |
|
Add the new VM to the specified pool. |
|
As of community.general 4.0.0, various options no longer have default values. These default values caused problems when users expected different behavior from Proxmox by default or filled options which caused problems when set. The value This affects the disk, cores, cpus, memory, onboot, swap, cpuunits options. Choices:
|
|
Public key to add to /root/.ssh/authorized_keys. This was added on Proxmox 4.2, it is ignored for earlier versions |
|
Remove container from all related configurations. For example backup jobs, replication jobs, or HA. Related ACLs and Firewall entries will always be removed. Used with state Choices:
|
|
sets DNS search domain for a container |
|
Indicate desired state of the instance Choices:
|
|
target storage Default: |
|
swap memory size in MB for instance This option has no default unless proxmox_default_behavior is set to |
|
List of tags to apply to the container. Tags must start with Tags are only available in Proxmox 7+. |
|
timeout for operations Default: |
|
Indicate if the container should be unprivileged. The default value for this parameter is Choices:
|
|
If This should only be used on personally controlled sites using self-signed certificates. Choices:
|
|
Specifies the instance ID. If not set the next available ID will be fetched from ProxmoxAPI. |
Attributes
Attribute |
Support |
Description |
---|---|---|
Support: none |
Can run in |
|
Support: none |
Will return details on what has changed (or possibly needs changing in |
Examples
- name: Create new container with minimal options
community.general.proxmox:
vmid: 100
node: uk-mc02
api_user: root@pam
api_password: 1q2w3e
api_host: node1
password: 123456
hostname: example.org
ostemplate: 'local:vztmpl/ubuntu-14.04-x86_64.tar.gz'
- name: Create new container with hookscript and description
community.general.proxmox:
vmid: 100
node: uk-mc02
api_user: root@pam
api_password: 1q2w3e
api_host: node1
password: 123456
hostname: example.org
ostemplate: 'local:vztmpl/ubuntu-14.04-x86_64.tar.gz'
hookscript: 'local:snippets/vm_hook.sh'
description: created with ansible
- name: Create new container automatically selecting the next available vmid.
community.general.proxmox:
node: 'uk-mc02'
api_user: 'root@pam'
api_password: '1q2w3e'
api_host: 'node1'
password: '123456'
hostname: 'example.org'
ostemplate: 'local:vztmpl/ubuntu-14.04-x86_64.tar.gz'
- name: Create new container with minimal options with force(it will rewrite existing container)
community.general.proxmox:
vmid: 100
node: uk-mc02
api_user: root@pam
api_password: 1q2w3e
api_host: node1
password: 123456
hostname: example.org
ostemplate: 'local:vztmpl/ubuntu-14.04-x86_64.tar.gz'
force: true
- name: Create new container with minimal options use environment PROXMOX_PASSWORD variable(you should export it before)
community.general.proxmox:
vmid: 100
node: uk-mc02
api_user: root@pam
api_host: node1
password: 123456
hostname: example.org
ostemplate: 'local:vztmpl/ubuntu-14.04-x86_64.tar.gz'
- name: Create new container with minimal options defining network interface with dhcp
community.general.proxmox:
vmid: 100
node: uk-mc02
api_user: root@pam
api_password: 1q2w3e
api_host: node1
password: 123456
hostname: example.org
ostemplate: 'local:vztmpl/ubuntu-14.04-x86_64.tar.gz'
netif: '{"net0":"name=eth0,ip=dhcp,ip6=dhcp,bridge=vmbr0"}'
- name: Create new container with minimal options defining network interface with static ip
community.general.proxmox:
vmid: 100
node: uk-mc02
api_user: root@pam
api_password: 1q2w3e
api_host: node1
password: 123456
hostname: example.org
ostemplate: 'local:vztmpl/ubuntu-14.04-x86_64.tar.gz'
netif: '{"net0":"name=eth0,gw=192.168.0.1,ip=192.168.0.2/24,bridge=vmbr0"}'
- name: Create new container with minimal options defining a mount with 8GB
community.general.proxmox:
vmid: 100
node: uk-mc02
api_user: root@pam
api_password: 1q2w3e
api_host: node1
password: 123456
hostname: example.org
ostemplate: local:vztmpl/ubuntu-14.04-x86_64.tar.gz'
mounts: '{"mp0":"local:8,mp=/mnt/test/"}'
- name: Create new container with minimal options defining a cpu core limit
community.general.proxmox:
vmid: 100
node: uk-mc02
api_user: root@pam
api_password: 1q2w3e
api_host: node1
password: 123456
hostname: example.org
ostemplate: local:vztmpl/ubuntu-14.04-x86_64.tar.gz'
cores: 2
- name: Create a new container with nesting enabled and allows the use of CIFS/NFS inside the container.
community.general.proxmox:
vmid: 100
node: uk-mc02
api_user: root@pam
api_password: 1q2w3e
api_host: node1
password: 123456
hostname: example.org
ostemplate: local:vztmpl/ubuntu-14.04-x86_64.tar.gz'
features:
- nesting=1
- mount=cifs,nfs
- name: >
Create a linked clone of the template container with id 100. The newly created container with be a
linked clone, because no storage parameter is defined
community.general.proxmox:
vmid: 201
node: uk-mc02
api_user: root@pam
api_password: 1q2w3e
api_host: node1
clone: 100
hostname: clone.example.org
- name: Create a full clone of the container with id 100
community.general.proxmox:
vmid: 201
node: uk-mc02
api_user: root@pam
api_password: 1q2w3e
api_host: node1
clone: 100
hostname: clone.example.org
storage: local
- name: Start container
community.general.proxmox:
vmid: 100
api_user: root@pam
api_password: 1q2w3e
api_host: node1
state: started
- name: >
Start container with mount. You should enter a 90-second timeout because servers
with additional disks take longer to boot
community.general.proxmox:
vmid: 100
api_user: root@pam
api_password: 1q2w3e
api_host: node1
state: started
timeout: 90
- name: Stop container
community.general.proxmox:
vmid: 100
api_user: root@pam
api_password: 1q2w3e
api_host: node1
state: stopped
- name: Stop container with force
community.general.proxmox:
vmid: 100
api_user: root@pam
api_password: 1q2w3e
api_host: node1
force: true
state: stopped
- name: Restart container(stopped or mounted container you can't restart)
community.general.proxmox:
vmid: 100
api_user: root@pam
api_password: 1q2w3e
api_host: node1
state: restarted
- name: Remove container
community.general.proxmox:
vmid: 100
api_user: root@pam
api_password: 1q2w3e
api_host: node1
state: absent
Collection links
Issue Tracker Repository (Sources) Submit a bug report Request a feature Communication