community.general.aerospike_migrations (8.5.0) — module

Check or wait for migrations between nodes

Authors: Albert Autin (@Alb0t)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

This can be used to check for migrations in a cluster. This makes it easy to do a rolling upgrade/update on Aerospike nodes.

If waiting for migrations is not desired, simply just poll until port 3000 if available or asinfo -v status returns ok

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# check for migrations on local node
- name: Wait for migrations on local node before proceeding
  community.general.aerospike_migrations:
    host: "localhost"
    connect_timeout: 2000
    consecutive_good_checks: 5
    sleep_between_checks: 15
    tries_limit: 600
    local_only: false
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# example playbook:
- name: Upgrade aerospike
  hosts: all
  become: true
  serial: 1
  tasks:
    - name: Install dependencies
      ansible.builtin.apt:
        name:
            - python
            - python-pip
            - python-setuptools
        state: latest
    - name: Setup aerospike
      ansible.builtin.pip:
          name: aerospike
# check for migrations every (sleep_between_checks)
# If at least (consecutive_good_checks) checks come back OK in a row, then return OK.
# Will exit if any exception, which can be caused by bad nodes,
# nodes not returning data, or other reasons.
# Maximum runtime before giving up in this case will be:
# Tries Limit * Sleep Between Checks * delay * retries
    - name: Wait for aerospike migrations
      community.general.aerospike_migrations:
          local_only: true
          sleep_between_checks: 1
          tries_limit: 5
          consecutive_good_checks: 3
          fail_on_cluster_change: true
          min_cluster_size: 3
          target_cluster_size: 4
      register: migrations_check
      until: migrations_check is succeeded
      changed_when: false
      delay: 60
      retries: 120
    - name: Another thing
      ansible.builtin.shell: |
          echo foo
    - name: Reboot
      ansible.builtin.reboot:

Inputs

    
host:
    default: localhost
    description:
    - Which host do we use as seed for info connection
    required: false
    type: str

port:
    default: 3000
    description:
    - Which port to connect to Aerospike on (service port)
    required: false
    type: int

local_only:
    description:
    - Do you wish to only check for migrations on the local node before returning, or
      do you want all nodes in the cluster to finish before returning?
    required: true
    type: bool

tries_limit:
    default: 300
    description:
    - How many times do we poll before giving up and failing?
    required: false
    type: int

migrate_rx_key:
    default: migrate_rx_partitions_remaining
    description:
    - The metric key used to determine if we have rx migrations remaining. Changeable
      due to backwards compatibility.
    required: false
    type: str

migrate_tx_key:
    default: migrate_tx_partitions_remaining
    description:
    - The metric key used to determine if we have tx migrations remaining. Changeable
      due to backwards compatibility.
    required: false
    type: str

connect_timeout:
    default: 1000
    description:
    - How long to try to connect before giving up (milliseconds)
    required: false
    type: int

min_cluster_size:
    default: 1
    description:
    - Check will return bad until cluster size is met or until tries is exhausted
    required: false
    type: int

target_cluster_size:
    description:
    - When all aerospike builds in the cluster are greater than version 4.3, then the
      C(cluster-stable) info command will be used. Inside this command, you can optionally
      specify what the target cluster size is - but it is not necessary. You can still
      rely on min_cluster_size if you don't want to use this option.
    - If this option is specified on a cluster that has at least 1 host <4.3 then it will
      be ignored until the min version reaches 4.3.
    required: false
    type: int

sleep_between_checks:
    default: 60
    description:
    - How long to sleep between each check (seconds).
    required: false
    type: int

fail_on_cluster_change:
    default: true
    description:
    - Fail if the cluster key changes if something else is changing the cluster, we may
      want to fail
    required: false
    type: bool

consecutive_good_checks:
    default: 3
    description:
    - How many times should the cluster report "no migrations" consecutively before returning
      OK back to ansible?
    required: false
    type: int