community.proxmox.proxmox_cluster_ha_rules module – Management of HA rules

Note

This module is part of the community.proxmox collection (version 1.4.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_cluster_ha_rules.

New in community.proxmox 1.4.0

Synopsis

  • Configure ha rules /cluster/ha/rules.

Requirements

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

  • proxmoxer >= 2.0

  • requests

Parameters

Parameter

Comments

affinity

string

Describes whether the HA resource are supposed to be kept on the same node positive, or are supposed to be kept on separate nodes negative. Required if type=resource-affinity.

Choices:

  • "positive"

  • "negative"

api_host

string / required

Specify the target host of the Proxmox VE cluster.

Uses the PROXMOX_HOST 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_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.

comment

string

Description

disable

boolean

Whether the HA rule is disabled. If not specified, the Proxmox API default false will be used.

Choices:

  • false

  • true

force

boolean

Existing rules with a specific type can not be changed to the other type. If force=true, the existing rule will be deleted and recreated with the new type.

Choices:

  • false ← (default)

  • true

name

string / required

HA rule identifier.

nodes

list / elements=string

List of cluster node members, where a priority can be given to each node. A resource bound to a group will run on the available nodes with the highest priority. If there are more nodes in the highest priority class, the services will get distributed to those nodes. The priorities have a relative meaning only. The higher the number, the higher the priority. It can either be a string node_name:priority,node_name:priority or an actual list of strings. Required if type=node-affinity.

resources

list / elements=string

List of HA resource IDs. It can either be a string vm:100,ct:101 or an actual list of strings.

state

string / required

create or delete rule

Choices:

  • "present"

  • "absent"

strict

boolean

If false, the HA resource can also be moved to other nodes if there is none of the specified nodes available. If not specified, the Proxmox API default false will be used.

Choices:

  • false

  • true

type

string

HA rule type.

Choices:

  • "node-affinity"

  • "resource-affinity"

validate_certs

boolean

If false, SSL certificates will not be validated.

This should only be used on personally controlled sites using self-signed certificates.

Uses the PROXMOX_VALIDATE_CERTS environment variable if not specified.

Choices:

  • false ← (default)

  • true

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.

Examples

- name: Configure ha rule (node-affinity)
  community.proxmox.proxmox_cluster_ha_rules:
    api_host: "{{ proxmox_api_host }}"
    api_user: "{{ proxmox_api_user }}"
    api_token_id: "{{ proxmox_api_token_id }}"
    api_token_secret: "{{ proxmox_api_token_secret }}"
    name: node-affinity-rule-1
    state: present
    type: node-affinity
    comment: VM 100 is supposed run on proxmox02
    nodes:
      - proxmox01:10
      - proxmox02:20
    resources:
      - vm:100
    disable: false
  delegate_to: localhost

- name: Configure ha rule (node-affinity) - nodes and resources can also be provided as str
  community.proxmox.proxmox_cluster_ha_rules:
    api_host: "{{ proxmox_api_host }}"
    api_user: "{{ proxmox_api_user }}"
    api_token_id: "{{ proxmox_api_token_id }}"
    api_token_secret: "{{ proxmox_api_token_secret }}"
    name: node-affinity-rule-2
    state: present
    type: node-affinity
    comment: VM 100 is supposed to run on proxmox02
    nodes: proxmox01:10,proxmox02:20
    resources: vm:100
    disable: false
  delegate_to: localhost

- name: Configure ha rule (resource-affinity) - resource affinity
  community.proxmox.proxmox_cluster_ha_rules:
    api_host: "{{ proxmox_api_host }}"
    api_user: "{{ proxmox_api_user }}"
    api_token_id: "{{ proxmox_api_token_id }}"
    api_token_secret: "{{ proxmox_api_token_secret }}"
    name: resource-affinity-rule-1
    state: present
    type: resource-affinity
    comment: VM 100 and 101 are supposed to be kept on the same node
    affinity: positive
    resources:
      - vm:100
      - vm:101
    disable: false
  delegate_to: localhost

- name: Configure ha rule (resource-affinity) - resource anti-affinity
  community.proxmox.proxmox_cluster_ha_rules:
    api_host: "{{ proxmox_api_host }}"
    api_user: "{{ proxmox_api_user }}"
    api_token_id: "{{ proxmox_api_token_id }}"
    api_token_secret: "{{ proxmox_api_token_secret }}"
    name: resource-affinity-rule-1
    state: present
    type: resource-affinity
    comment: VM 100 and 101 are supposed to be kept on different nodes
    affinity: negative
    resources:
      - vm:100
      - vm:101
    disable: false
  delegate_to: localhost

Return Values

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

Key

Description

rule

dictionary

A representation of the rule.

Returned: success

Sample: {"comment": "My first ha rule", "digest": "f19acd44b43052343763cd9fd45a03b7449b3e2f", "disable": 0, "nodes": "proxmox01:10,proxmox02:10", "order": 2, "resources": "vm:100", "rule": "ha-rule1", "strict": 0, "type": "node-affinity"}

Authors

  • Reto Kupferschmid (@rekup)