ondrejhome.ha_cluster.crm_wait_for (1.0.2) — module

Wait for resource in pacemaker cluster to get into requested state before continuing.

| "added in version" 2.10 of ondrejhome.ha_cluster"

Authors: Ondrej Famera (@OndrejHome)

preview | supported by community

Install collection

Install with ansible-galaxy collection install ondrejhome.ha_cluster:==1.0.2


Add to requirements.yml

  collections:
    - name: ondrejhome.ha_cluster
      version: 1.0.2

Description

This module can wait for resource in cluster to become simply present/absent from configuration or

for resource defined in cluster to get into desired state.

Optionally you can define on which node(s) the state for resource should be achieved.

It is possible to adjust C(timeout) for how long to wait before failing and C(sleep) interval between the checks of cluster state.

If resource is expected to take some time to reach desired state the C(delay) defines how long to wait before first check.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: wait for 'resA' resource to get defined in cluster config
  crm_wait_for:
    resource: 'resA'
    state: 'present'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: wait for 'resA' resource to get removed from cluster configuration
  crm_wait_for:
    resource: 'resA'
    state: 'absent'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: wait for 'resA' resource to get 'Started' anywhere in cluster, wait 2 seconds between checks
  crm_wait_for:
    resource: 'resA'
    state: 'Started'
    sleep: '2'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: wait for 'resA' resource to get 'Stopped' on all cluster nodes, delay first check for 3 seconds
  crm_wait_for:
    resource: 'resA'
    state: 'Stopped'
    delay: '3'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: wait for 'resA' resource to get 'Stopped' on node 'node-b' (succeeds when 'resA' is not running or when it is running on any other node than 'node-b')
  crm_wait_for:
    resource: 'resA'
    state: 'Stopped'
    node_list: ['node-b']
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: wait for 'resB' resource to get promoted to 'Master' on node 'node-a'
  crm_wait_for:
    resource: 'resB'
    state: 'Master'
    node_list: ['node-a']
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: wait up to 20 seconds for 'resC' resource to get started both node 'node-a' and node 'node-b'
  crm_wait_for:
    timeout: '20'
    resource: 'resC'
    state: 'Started'
    node_list: ['node-a', 'node-b']

Inputs

    
delay:
    default: 0
    description:
    - Number of seconds to delay first check.
    required: false
    type: int

sleep:
    default: 2
    description:
    - Number of seconds to sleep/wait between checks.
    required: false
    type: int

state:
    choices:
    - present
    - absent
    - Started
    - Stopped
    - Master
    - Slave
    default: present
    description:
    - '''present'' - waits for resource is present/defined in cluster'
    - '''absent'' - waits for resource to not exists in cluster configuration'
    - '''Started'' - waits for resource to reach ''Started'' state'
    - '''Stopped'' - waits for resource to reach ''Stopped'' state'
    - '''Master'' - waits for resource to reach ''Master'' state'
    - '''Slave'' - waits for resource to reach ''Slave'' state'
    required: false
    type: str

timeout:
    default: 60
    description:
    - Number of seconds to wait for condition before failing (after initial C(delay)).
    required: false
    type: int

resource:
    description:
    - Name of resource to wait for.
    - For cloned resource use the name of 'primitive resource' (typically name without
      '-clone'/'-master'/'-promotable' suffix)
    required: true
    type: str

node_list:
    default: []
    description:
    - List of nodes on which the desired stated is expected (only for 'Started'/'Stopped'/'Master'/'Slave'
      states.
    - For state 'Stopped' the default is 'all cluster nodes', while for other states the
      default is 'any node'.
    elements: str
    required: false
    type: list

Outputs

cluster_nodes:
  description: List of cluster nodes in cluster.
  returned: always
  sample:
  - node-a
  - node-b
  type: list
elapsed:
  description: The number of seconds that elapsed while waiting
  returned: always
  sample: 23
  type: int
rsc_active_node_set:
  description: (Only present when state is 'Stopped'/'Started'/'Master'/'Slave').
    List of nodes where resource is in desired state.
  returned: always
  sample:
  - node-b
  type: list
rsc_inactive_node_set:
  description: (Only present when state is 'Stopped'). List of nodes where resource
    is not running.
  returned: always
  sample:
  - node-a
  type: list