From 183b16c5169d366708c9e8de479503f12482192b Mon Sep 17 00:00:00 2001 From: Raoul Scarazzini Date: Fri, 6 Jul 2018 15:21:24 +0200 Subject: [PATCH] Fix custom STONITH compute names in IHA playbook Today when STONITH for the compute nodes is already configured in the TripleO deployment and the name of these STONITH resources is not "ipmilan-" the task will likely fail. This commit fixes the way STONITH levels are managed, making the task to not rely anymore on the fact that a user will configure also STONITH with the instance HA playbooks, but reading dynamically the name of the resources. It also takes care about it while removing the IHA steps, preserving the idempotent principle. Closes-Bug: #1780434 Change-Id: I2f8351cf62cddd420c257110d60442ca4243a43d --- roles/instance-ha/tasks/apply.yml | 11 ++++------- roles/instance-ha/tasks/undo.yml | 9 +++++++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/roles/instance-ha/tasks/apply.yml b/roles/instance-ha/tasks/apply.yml index fea181f..3e840cf 100644 --- a/roles/instance-ha/tasks/apply.yml +++ b/roles/instance-ha/tasks/apply.yml @@ -280,11 +280,6 @@ pcs constraint order start openstack-nova-conductor-clone then nova-compute-checkevacuate-clone require-all=false when: release in [ 'liberty', 'rhos-8', 'mitaka', 'rhos-9' ] - - name: Check if ipmi exists for all compute nodes - shell: | - pcs stonith show ipmilan-{{ hostvars[item]['ansible_hostname'] }} - with_items: "{{ groups['compute'] }}" - - name: Set requires to fencing as default for all resources (Pike/RHOS-12) shell: "pcs resource defaults requires=fencing" when: release in [ 'pike', 'rhos-12' ] @@ -319,8 +314,10 @@ shell: "pcs property set --node {{ hostvars[item]['ansible_hostname'] }} osprole=compute" with_items: "{{ groups['compute'] }}" - - name: Add pacemaker stonith devices of compute nodes to level 1 - shell: "pcs stonith level add 1 {{ hostvars[item]['ansible_hostname'] }} ipmilan-{{ hostvars[item]['ansible_hostname'] }},fence-nova" + - name: Add STONITH level definitions for compute nodes + shell: | + compute_stonith_name=$(cibadmin --query --xpath "//primitive[@class='stonith']/instance_attributes/nvpair[@value='{{ item }}']" | sed 's/.*id="\(.*\)-instance_attributes-pcmk_host_list".*/\1/g') + pcs stonith level add 1 {{ item }} $compute_stonith_name,fence-nova with_items: "{{ groups['compute'] }}" - name: Enable keystone resource diff --git a/roles/instance-ha/tasks/undo.yml b/roles/instance-ha/tasks/undo.yml index 278324b..5ee6187 100644 --- a/roles/instance-ha/tasks/undo.yml +++ b/roles/instance-ha/tasks/undo.yml @@ -1,5 +1,14 @@ --- - block: + - name: Remove STONITH level definitions for compute nodes + shell: | + compute_stonith_name=$(cibadmin --query --xpath "//primitive[@class='stonith']/instance_attributes/nvpair[@value='{{ item }}']" | sed 's/.*id="\(.*\)-instance_attributes-pcmk_host_list".*/\1/g') + for stonith_level in $(cibadmin --query --xpath "//configuration/fencing-topology/fencing-level[@devices='$compute_stonith_name,fence-nova'][@index='1'][@target='{{ item }}']" --node-path) + do + pcs stonith level delete 1 {{ item }} $compute_stonith_name,fence-nova + done + with_items: "{{ groups['compute'] }}" + - name: Remove fence-nova STONITH device shell: | for stonithid in $(pcs stonith show | awk '/fence_compute/ {print $1}')