Reputation: 1324
I want to utilize windows failover cluster generic service role for my application. and I'm trying to figure out how to perform the upgrades.
I've read there is an option to perform a "cluster-aware" upgrade, I.E: hand the cluster some MSI \ installer and let him be in charge of upgrading all the nodes.
Has anyone that used that feature can:
Upvotes: 2
Views: 682
Reputation: 895
We have clustered Windows Services that are use the .NET
stack. At the moment, each cluster role are hosted on two nodes only. Deployment and upgrade process is performed via Ansible
. The following snippets cover upgrade part only.
For service deployment are used Nuget
packages. Used .nuspec
is represented below. So packages are represent the .zip
archives, which contains all content in the root.
<?xml version="1.0"?>
<package>
<metadata>
<id>$Id$</id>
<version>$Version$</version>
<authors>$Authors$</authors>
<description> $Description$ </description>
<releaseNotes>$ReleaseNotes$</releaseNotes>
</metadata>
<files>
<file src="$PackageInput$" target=" "/>
</files>
</package>
The described below role could be used for composite cluster roles, when one cluster role contains multiple resources.
- name: 'Copy the cluster_role.ps1 to all hosts'
win_copy:
src : 'cluster_role.ps1'
dest: 'cluster_role.ps1'
This task is needed to copies to all hosts the PowerShell
script, which is required for detecting the owner node and for moving role between nodes.
param([String]$ClusterRoleName, [String]$ExcludeNode)
# Task: Define the owner node
if ($ClusterRoleName -ne [string]::Empty -and $ExcludeNode -eq [string]::Empty)
{
Get-ClusterResource -Name $ClusterRoleName | Format-List -Property OwnerNode
exit
}
# Task: Move the cluster role
if ($ClusterRoleName -ne [string]::Empty -and $ExcludeNode -ne [string]::Empty)
{
Move-ClusterGroup $ClusterRoleName (Get-ClusterNode | Where-Object { $_.State -eq 'Up' -and $_.Name -ne $ExcludeNode })
exit
}
- name: 'Define the owner node'
win_shell: 'cluster_role.ps1 -ClusterRoleName {{ cluster_role }}'
register: owner_node
run_once: True
when: 'cluster_role is defined'
- name: 'Define the owner node metadata'
set_fact:
owner_node_host: '{{ owner_node.stdout.split(":")[1] | trim }}.{{ windows_domain }}'
owner_node_name: '{{ owner_node.stdout.split(":")[1] | trim }}'
run_once: True
when: 'cluster_role is defined'
These tasks are needed to detect the owner node. The first task returns the owner node, for example: s001srv000
. The second task creates two variables following types:
owner_node_host : s001srv.domain.net
owner_node_name: s001srv000
- name: 'Apply the application roles on the inactive nodes'
include_role:
name: '{{ item }}'
when : 'cluster_role is defined and (cluster_sets is defined or cluster_full is defined) and owner_node_host != inventory_hostname'
with_items: '{{ dependencies }}'
These task is include another roles such as downloading new version package, generating service configuration depending on environment, etc. Performs on inactive nodes.
- pause:
prompt : 'A manual failover must be manually performed'
minutes: 30
run_once : True
when: 'cluster_full is defined and environment_type == "prod"'
- name: 'Move the cluster role'
win_shell: 'cluster_role.ps1 -ClusterRoleName {{ cluster_role }} -ExcludeNode {{ owner_node_name }}'
run_once : True
when: 'cluster_move is defined or cluster_full is defined'
These tasks are needed to control upgrade flow, if current environment is STG, then upgrade will be performed automatically, otherwise with a manual failover at pause moment.
- name: 'Apply the application roles on the nodes which were active a moment ago'
include_role:
name: '{{ item }}'
when : 'cluster_role is defined and cluster_full is defined and owner_node_host == inventory_hostname'
These task is the same as 'Apply the application roles on the inactive nodes'
, but for nodes, which were active a moment ago.
Upvotes: 2