From d4247058ac6b1e266bf12305257719285ed2c06c Mon Sep 17 00:00:00 2001 From: Sergei Petrosian Date: Fri, 16 Feb 2024 14:56:03 +0100 Subject: [PATCH 1/4] feat: Implement WRITE_LEASE_VALIDITY --- README.md | 6 ++++++ tasks/main.yml | 6 ++++++ templates/configure_ag.j2 | 6 +++++- tests/tests_configure_ha_cluster_external.yml | 2 ++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 24c74f4d..7a922de8 100644 --- a/README.md +++ b/README.md @@ -1068,6 +1068,8 @@ For more information, see the `fedora.linux_system_roles.ha_cluster` role docume - attrs: - name: notify value: true + - name: on_fail + value: demote ha_cluster_constraints_colocation: - resource_leader: id: ag_cluster-clone @@ -1172,6 +1174,8 @@ Note that production environments require Pacemaker configured with fencing agen - attrs: - name: notify value: true + - name: on_fail + value: demote ha_cluster_constraints_colocation: - resource_leader: id: ag_cluster-clone @@ -1310,6 +1314,8 @@ This example playbooks sets the `firewall` variables for the `fedora.linux_syste - attrs: - name: notify value: true + - name: on_fail + value: demote ha_cluster_constraints_colocation: - resource_leader: id: ag_cluster-clone diff --git a/tasks/main.yml b/tasks/main.yml index cae30fab..1ea51e23 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1035,6 +1035,12 @@ any_errors_fatal: true when: mssql_ha_configure | bool block: + # Required for configure_ag.j2 to set WRITE_LEASE_VALIDITY based on + # mssql-server version + - name: Get mssql-server version to see if WRITE_LEASE_VALIDITY is available + package_facts: + no_log: "{{ __mssql_gather_facts_no_log | d(false) }}" + - name: Verify that hosts with mssql_ha_replica_type=primary is available assert: that: ansible_play_hosts | diff --git a/templates/configure_ag.j2 b/templates/configure_ag.j2 index 8f246b54..b882aeb8 100644 --- a/templates/configure_ag.j2 +++ b/templates/configure_ag.j2 @@ -219,7 +219,11 @@ BEGIN CREATE AVAILABILITY GROUP {{ mssql_ha_ag_name }} WITH ( DB_FAILOVER = {{ __mssql_ha_db_failover }}, - CLUSTER_TYPE = {{ mssql_ha_ag_cluster_type }} + CLUSTER_TYPE = {{ mssql_ha_ag_cluster_type }}, +{% if ansible_facts.packages['mssql-server'][0]['version'] + is version('15.0.4153.1', '>=') %} + WRITE_LEASE_VALIDITY=20 +{% endif %} ) FOR REPLICA ON {# Sort ansible_play_hosts #} diff --git a/tests/tests_configure_ha_cluster_external.yml b/tests/tests_configure_ha_cluster_external.yml index 24e9ec9c..b78fa893 100644 --- a/tests/tests_configure_ha_cluster_external.yml +++ b/tests/tests_configure_ha_cluster_external.yml @@ -86,6 +86,8 @@ - attrs: - name: notify value: true + - name: on_fail + value: demote ha_cluster_constraints_colocation: - resource_leader: id: ag_cluster-clone From 91db3bf3ff59b0a4b71536d8f9b4f26ea093892b Mon Sep 17 00:00:00 2001 From: Sergei Petrosian Date: Fri, 16 Feb 2024 14:56:18 +0100 Subject: [PATCH 2/4] Fix indentation in yaml --- README.md | 126 +++++++++--------- tests/tests_configure_ha_cluster_external.yml | 36 ++--- 2 files changed, 81 insertions(+), 81 deletions(-) diff --git a/README.md b/README.md index 7a922de8..f3c41a0f 100644 --- a/README.md +++ b/README.md @@ -1031,31 +1031,31 @@ For more information, see the `fedora.linux_system_roles.ha_cluster` role docume ha_cluster_sbd_enabled: true ha_cluster_cluster_properties: - attrs: - - name: cluster-recheck-interval - value: 2min - - name: start-failure-is-fatal - value: true - - name: stonith-enabled - value: true - - name: stonith-watchdog-timeout - value: 10 + - name: cluster-recheck-interval + value: 2min + - name: start-failure-is-fatal + value: true + - name: stonith-enabled + value: true + - name: stonith-watchdog-timeout + value: 10 ha_cluster_resource_primitives: - id: ag_cluster agent: ocf:mssql:ag instance_attrs: - attrs: - - name: ag_name - value: "{{ mssql_ha_ag_name }}" + - name: ag_name + value: "{{ mssql_ha_ag_name }}" meta_attrs: - attrs: - - name: failure-timeout - value: 60s + - name: failure-timeout + value: 60s - id: virtualip agent: ocf:heartbeat:IPaddr2 instance_attrs: - attrs: - - name: ip - value: "{{ mssql_ha_virtual_ip }}" + - name: ip + value: "{{ mssql_ha_virtual_ip }}" operations: - action: monitor attrs: @@ -1066,10 +1066,10 @@ For more information, see the `fedora.linux_system_roles.ha_cluster` role docume promotable: yes meta_attrs: - attrs: - - name: notify - value: true - - name: on_fail - value: demote + - name: notify + value: true + - name: on_fail + value: demote ha_cluster_constraints_colocation: - resource_leader: id: ag_cluster-clone @@ -1127,41 +1127,41 @@ Note that production environments require Pacemaker configured with fencing agen ha_cluster_hacluster_password: "p@55w0rD4" ha_cluster_cluster_properties: - attrs: - - name: cluster-recheck-interval - value: 2min - - name: start-failure-is-fatal - value: true - - name: stonith-enabled - value: true + - name: cluster-recheck-interval + value: 2min + - name: start-failure-is-fatal + value: true + - name: stonith-enabled + value: true ha_cluster_resource_primitives: - id: vmfence agent: stonith:fence_vmware_soap instance_attrs: - attrs: - - name: username - value: vmware_Login - - name: passwd - value: vmware_password - - name: ip - value: vmware_ip - - name: ssl_insecure - value: 1 + - name: username + value: vmware_Login + - name: passwd + value: vmware_password + - name: ip + value: vmware_ip + - name: ssl_insecure + value: 1 - id: ag_cluster agent: ocf:mssql:ag instance_attrs: - attrs: - - name: ag_name - value: "{{ mssql_ha_ag_name }}" + - name: ag_name + value: "{{ mssql_ha_ag_name }}" meta_attrs: - attrs: - - name: failure-timeout - value: 60s + - name: failure-timeout + value: 60s - id: virtualip agent: ocf:heartbeat:IPaddr2 instance_attrs: - attrs: - - name: ip - value: "{{ mssql_ha_virtual_ip }}" + - name: ip + value: "{{ mssql_ha_virtual_ip }}" operations: - action: monitor attrs: @@ -1172,10 +1172,10 @@ Note that production environments require Pacemaker configured with fencing agen promotable: yes meta_attrs: - attrs: - - name: notify - value: true - - name: on_fail - value: demote + - name: notify + value: true + - name: on_fail + value: demote ha_cluster_constraints_colocation: - resource_leader: id: ag_cluster-clone @@ -1247,33 +1247,33 @@ This example playbooks sets the `firewall` variables for the `fedora.linux_syste - fence-agents-azure-arm ha_cluster_cluster_properties: - attrs: - - name: cluster-recheck-interval - value: 2min - - name: start-failure-is-fatal - value: true - - name: stonith-enabled - value: true - - name: stonith-timeout + - name: cluster-recheck-interval + value: 2min + - name: start-failure-is-fatal + value: true + - name: stonith-enabled + value: true + - name: stonith-timeout value: 900 ha_cluster_resource_primitives: - id: rsc_st_azure agent: stonith:fence_azure_arm instance_attrs: - attrs: - - name: login - value: ApplicationID - - name: passwd - value: servicePrincipalPassword - - name: resourceGroup - value: resourceGroupName - - name: tenantId - value: tenantID - - name: subscriptionId - value: subscriptionID - - name: power_timeout - value: 240 - - name: pcmk_reboot_timeout - value: 900 + - name: login + value: ApplicationID + - name: passwd + value: servicePrincipalPassword + - name: resourceGroup + value: resourceGroupName + - name: tenantId + value: tenantID + - name: subscriptionId + value: subscriptionID + - name: power_timeout + value: 240 + - name: pcmk_reboot_timeout + value: 900 - id: azure_load_balancer agent: azure-lb instance_attrs: diff --git a/tests/tests_configure_ha_cluster_external.yml b/tests/tests_configure_ha_cluster_external.yml index b78fa893..dfd0f1f9 100644 --- a/tests/tests_configure_ha_cluster_external.yml +++ b/tests/tests_configure_ha_cluster_external.yml @@ -49,31 +49,31 @@ ha_cluster_sbd_enabled: true ha_cluster_cluster_properties: - attrs: - - name: cluster-recheck-interval - value: 2min - - name: start-failure-is-fatal - value: true - - name: stonith-enabled - value: true - - name: stonith-watchdog-timeout - value: 10 + - name: cluster-recheck-interval + value: 2min + - name: start-failure-is-fatal + value: true + - name: stonith-enabled + value: true + - name: stonith-watchdog-timeout + value: 10 ha_cluster_resource_primitives: - id: ag_cluster agent: ocf:mssql:ag instance_attrs: - attrs: - - name: ag_name - value: "{{ mssql_ha_ag_name }}" + - name: ag_name + value: "{{ mssql_ha_ag_name }}" meta_attrs: - attrs: - - name: failure-timeout - value: 60s + - name: failure-timeout + value: 60s - id: virtualip agent: ocf:heartbeat:IPaddr2 instance_attrs: - attrs: - - name: ip - value: "{{ mssql_ha_virtual_ip }}" + - name: ip + value: "{{ mssql_ha_virtual_ip }}" operations: - action: monitor attrs: @@ -84,10 +84,10 @@ promotable: true meta_attrs: - attrs: - - name: notify - value: true - - name: on_fail - value: demote + - name: notify + value: true + - name: on_fail + value: demote ha_cluster_constraints_colocation: - resource_leader: id: ag_cluster-clone From cc5e078c26e5105382866b35f0fa90bda5bca643 Mon Sep 17 00:00:00 2001 From: Sergei Petrosian Date: Fri, 16 Feb 2024 15:09:49 +0100 Subject: [PATCH 3/4] Use WRITE_LEASE_VALIDITY=10 --- templates/configure_ag.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/configure_ag.j2 b/templates/configure_ag.j2 index b882aeb8..fded62ed 100644 --- a/templates/configure_ag.j2 +++ b/templates/configure_ag.j2 @@ -222,7 +222,7 @@ BEGIN CLUSTER_TYPE = {{ mssql_ha_ag_cluster_type }}, {% if ansible_facts.packages['mssql-server'][0]['version'] is version('15.0.4153.1', '>=') %} - WRITE_LEASE_VALIDITY=20 + WRITE_LEASE_VALIDITY=10 {% endif %} ) FOR REPLICA ON From a57168c60f6c6b4b14bca516519ca6310dacaad8 Mon Sep 17 00:00:00 2001 From: Sergei Petrosian Date: Mon, 19 Feb 2024 12:33:07 +0100 Subject: [PATCH 4/4] Fix typo s/on_fail/on-fail/g --- README.md | 6 +++--- tests/tests_configure_ha_cluster_external.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f3c41a0f..4d66dd70 100644 --- a/README.md +++ b/README.md @@ -1068,7 +1068,7 @@ For more information, see the `fedora.linux_system_roles.ha_cluster` role docume - attrs: - name: notify value: true - - name: on_fail + - name: on-fail value: demote ha_cluster_constraints_colocation: - resource_leader: @@ -1174,7 +1174,7 @@ Note that production environments require Pacemaker configured with fencing agen - attrs: - name: notify value: true - - name: on_fail + - name: on-fail value: demote ha_cluster_constraints_colocation: - resource_leader: @@ -1314,7 +1314,7 @@ This example playbooks sets the `firewall` variables for the `fedora.linux_syste - attrs: - name: notify value: true - - name: on_fail + - name: on-fail value: demote ha_cluster_constraints_colocation: - resource_leader: diff --git a/tests/tests_configure_ha_cluster_external.yml b/tests/tests_configure_ha_cluster_external.yml index dfd0f1f9..5a64cadc 100644 --- a/tests/tests_configure_ha_cluster_external.yml +++ b/tests/tests_configure_ha_cluster_external.yml @@ -86,7 +86,7 @@ - attrs: - name: notify value: true - - name: on_fail + - name: on-fail value: demote ha_cluster_constraints_colocation: - resource_leader: