From d88d758f81170362ac0d8705d0a93567e95bf56d Mon Sep 17 00:00:00 2001 From: Juan Antonio Osorio Robles Date: Wed, 29 Nov 2017 08:27:29 +0000 Subject: [PATCH] Only include resource-agent tasks when pacemaker is running This removes all the checks for a running pacemaker from the resource-agent's tasks and puts that responsibility on the caller. Effectively cleaning up the resource-agent.yml code. --- tasks/legacy.yml | 4 +++- tasks/resource-agent.yml | 7 ------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/tasks/legacy.yml b/tasks/legacy.yml index 7735a15..f5935de 100644 --- a/tasks/legacy.yml +++ b/tasks/legacy.yml @@ -69,4 +69,6 @@ loop_control: loop_var: current_vip with_items: "{{ networks|default([])|json_query('[*].vips[]')|list }}" - when: node_hosting_the_vip.stdout == ansible_hostname + when: + - node_hosting_the_vip.stdout == ansible_hostname + - pacemaker_running diff --git a/tasks/resource-agent.yml b/tasks/resource-agent.yml index f5a9fc2..3db3115 100644 --- a/tasks/resource-agent.yml +++ b/tasks/resource-agent.yml @@ -14,36 +14,29 @@ command: pcs resource show {{ resource_agent_name }} ignore_errors: yes register: found_resource_agent - when: - - pacemaker_running - name: Delete {{ resource_agent_name }} Resource Agent command: pcs resource delete {{ resource_agent_name }} when: - - pacemaker_running - resource_agent.changed - found_resource_agent|succeeded - name: Add {{ resource_agent_name }} pacemaker resource agent command: pcs resource create {{ resource_agent_name }} ocf:heartbeat:ipsec tunnel={{ specific_tunnel }} vip={{ specific_vip }} --disabled when: - - pacemaker_running - resource_agent.changed or found_resource_agent|failed - name: Add collocation rule with VIP ( {{ resource_agent_name }} ) command: pcs constraint colocation add {{ resource_agent_name }} with ip-{{ specific_vip }} when: - - pacemaker_running - resource_agent.changed or found_resource_agent|failed - name: Add ordering rule with VIP ( {{ resource_agent_name }} ) command: pcs constraint order start ip-{{ specific_vip }} then {{ resource_agent_name }} when: - - pacemaker_running - resource_agent.changed or found_resource_agent|failed - name: Enable {{ resource_agent_name }} resource agent command: pcs resource enable {{ resource_agent_name }} when: - - pacemaker_running - resource_agent.changed or found_resource_agent|failed