community.proxmox.proxmox_pool_member module – Add or delete members from Proxmox VE cluster pools

Note

This module is part of the community.proxmox collection (version 2.0.0).

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.proxmox. You need further requirements to be able to use this module, see Requirements for details.

To use it in a playbook, specify: community.proxmox.proxmox_pool_member.

Synopsis

  • Add or remove members from a pool in Proxmox VE clusters.

  • Each member is a dict with either a vm key (vmid or VM name) or a storage key.

  • When exclusive=true, the pool membership is reconciled to match exactly members, ignoring state.

Requirements

The below requirements are needed on the host that executes this module.

  • proxmoxer >= 2.3

  • requests

Parameters

Parameter

Comments

api_host

string / required

Specify the target host of the Proxmox VE cluster.

Uses the PROXMOX_HOST environment variable if not specified.

api_otp

string

Specify the OTP.

Uses the PROXMOX_OTP environment variable if not specified.

api_password

string

Specify the password to authenticate with.

Uses the PROXMOX_PASSWORD environment variable if not specified.

api_port

integer

Specify the target port of the Proxmox VE cluster.

Uses the PROXMOX_PORT environment variable if not specified.

api_timeout

integer

Time limit for requests towards the Proxmox VE API.

Default: 5

api_token_id

string

Specify the token ID.

Uses the PROXMOX_TOKEN_ID environment variable if not specified.

api_token_secret

string

Specify the token secret.

Uses the PROXMOX_TOKEN_SECRET environment variable if not specified.

api_user

string / required

Specify the user to authenticate with.

Uses the PROXMOX_USER environment variable if not specified.

ca_path

path

Path to a local certificate, which will be used to verify TLS connections.

Ignored if validate_certs=false.

exclusive

boolean

When true, reconcile pool membership to match exactly members.

Members present in the pool but absent from members will be removed.

Members in members but absent from the pool will be added.

state is ignored when this option is true.

This option is not loop aware, so if you use `with_’ , it will be exclusive per iteration of the loop.

If you want multiple members in the pool you need to pass them all to `members’ in a single batch.

Choices:

  • false ← (default)

  • true

members

list / elements=dictionary / required

List of members to add or remove from the pool.

Each item is a dict with either a vm key (vmid or VM name) or a storage key (storage name as string).

storage

string

Storage name.

vm

string

VM id or VM name.

poolid

aliases: name

string / required

The pool ID.

state

string

Desired state for each member listed in members.

Ignored when exclusive=true.

Choices:

  • "present" ← (default)

  • "absent"

validate_certs

boolean

Validate the TLS certificates used for the connection to the Proxmox VE API.

May be set through the environment variable PROXMOX_VALIDATE_CERTS.

Choices:

  • false

  • true ← (default)

Attributes

Attribute

Support

Description

action_group

Action group: community.proxmox.proxmox

Use group/community.proxmox.proxmox in module_defaults to set defaults for this module.

check_mode

Support: full

Can run in check_mode and return changed status prediction without modifying target.

diff_mode

Support: full

Will return details on what has changed (or possibly needs changing in check_mode), when in diff mode.

See Also

See also

Authentication

Complete guide for the Proxmox API authentication

Examples

- name: Add VMs and a storage to a pool
  community.proxmox.proxmox_pool_member:
    api_host: node1
    api_user: root@pam
    api_password: password
    poolid: test
    members:
      - vm: 101
      - vm: pxe.home.arpa
      - storage: zfs-data

- name: Remove a VM and a storage from a pool
  community.proxmox.proxmox_pool_member:
    api_host: node1
    api_user: root@pam
    api_password: password
    poolid: test
    state: absent
    members:
      - vm: 101
      - storage: zfs-data

- name: Enforce exact pool membership (exclusive mode)
  community.proxmox.proxmox_pool_member:
    api_host: node1
    api_user: root@pam
    api_password: password
    poolid: test
    exclusive: true
    members:
      - vm: 101
      - storage: zfs-data

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

members

list / elements=dictionary

Final list of members in the pool after the operation.

Returned: success

Sample: [{"vm": "101"}, {"storage": "zfs-data"}]

msg

string

A short message on what the module did.

Returned: always

Sample: "Member 101 deleted from the pool test"

poolid

string

The pool ID.

Returned: success

Sample: "test"

Authors

  • Sergei Antipov (@UnderGreen)