node-upgrading.yml
Overview
The node-upgrading.yml file is an Ansible playbook designed to manage the upgrade process of block keeper nodes within an infrastructure. It orchestrates a series of steps such as stopping services, upgrading components, and restarting essential processes across a targeted set of hosts. The playbook allows for configurable behavior through variables and interacts primarily with the block-keeper role to apply the upgrade logic.
Purpose and Functionality
Automates the upgrade process for block keeper nodes.
Performs service stop, upgrade, and restart operations in a controlled sequence.
Supports flexible targeting of hosts via the
targetvariable, defaulting toblock_keepers.Controls upgrade behavior with flags such as
DELETE_DATA,DO_START, andFAST_UPDATE.Specifies which components to upgrade and the corresponding steps for each.
Playbook Structure
Play Name: Block keeper upgrading
Hosts: Defined by
targetvariable, defaults toblock_keepersPrivilege Escalation: Enabled with
become: yesto allow administrative operationsError Handling:
any_errors_fatal: trueto ensure playbook halts on any failureVariables:
DELETE_DATA(default:no): Controls whether node data should be deleted during the upgrade.DO_START(default:yes): Determines if services should be started after upgrade.FAST_UPDATE(default:yes): Enables a faster update procedure.UPGRADE: A list defining the upgrade steps for each component, with comments indicating the operations:node: executegrshcommand with stop and up operations.compose: executegrshwith down and up operations.aerospike: stop and start Aerospike service.logrotate: upgrade and restart logrotate service.
Roles:
block-keeper: The role responsible for implementing the upgrade operations on the nodes.
Variables
Variable | Type | Default | Description |
|---|---|---|---|
| string |
| Defines the inventory group or host(s) where the playbook runs. |
| boolean |
| Flag to indicate if node data should be deleted during the upgrade process. |
| boolean |
| Indicates whether to start services post-upgrade. |
| boolean |
| Enables a faster upgrade method, possibly skipping some slower steps. |
| list | See above | Specifies components and their upgrade steps in order. |
Roles and Interactions
block-keeper Role:
This role performs the actual tasks to upgrade each component listed in the
UPGRADEvariable.It executes commands such as
grshfor node and compose components, manages Aerospike service lifecycle, and handles logrotate service restart.The role's logic uses the control variables (
DELETE_DATA,DO_START,FAST_UPDATE) to customize the upgrade steps.
Host Interaction:
The playbook targets hosts defined by
target, enabling upgrades on selected nodes or groups.It requires privilege escalation to perform service management and file operations.
Usage Example
To run the upgrade on the default block_keepers hosts with default settings:
ansible-playbook node-upgrading.yml
To upgrade a specific host group block_keepers_test without deleting data and disabling fast update:
ansible-playbook node-upgrading.yml -e "target=block_keepers_test DELETE_DATA=no FAST_UPDATE=no"
Implementation Details
Uses Ansible's
any_errors_fatal: trueto ensure that any failure in the upgrade steps halts the playbook immediately, preventing partial upgrades.The
UPGRADElist is an ordered sequence determining the upgrade workflow, ensuring dependencies like stopping services before upgrading.The role integration abstracts the detailed commands and service management, enabling modular and reusable upgrade logic.
Variables provide a flexible mechanism to adapt upgrade behavior without modifying the playbook code.
Mermaid Diagram: Workflow of node-upgrading.yml
flowchart TD
Start["Start Playbook"]
SetHosts["Set hosts: target or 'block_keepers'"]
Become["Become: yes (privilege escalation)"]
InitVars["Initialize variables (DELETE_DATA, DO_START, FAST_UPDATE, UPGRADE)"]
CallRole["Call role: block-keeper"]
UpgradeNode["Upgrade node: grsh stop + up"]
UpgradeCompose["Upgrade compose: grsh down + up"]
UpgradeAerospike["Upgrade aerospike: stop + up"]
UpgradeLogrotate["Upgrade logrotate: up + restart"]
End["End Playbook"]
Start --> SetHosts --> Become --> InitVars --> CallRole
CallRole --> UpgradeNode --> UpgradeCompose --> UpgradeAerospike --> UpgradeLogrotate --> End
This flowchart illustrates the sequential execution flow from playbook start through variable initialization, role invocation, and component upgrade steps.