tripleo-ipsec/tasks/resource-agent.yml

53 lines
2.3 KiB
YAML

---
# This file means to be a generic way to add resource agents for VIPs
# The following are assumed to be passed:
#
# * current_vip.name: Name of the network
# * current_vip.ip: the VIP
- name: Set specific resource agent facts
set_fact:
resource_agent_name: tripleo-ipsec-{{ current_vip.name }}
specific_tunnel: overcloud-{{ current_vip.name }}-vip-tunnel
fallback_tunnel: overcloud-{{ current_vip.name }}-node-to-vip-tunnel
specific_vip: "{{ current_vip.ip }}"
- name: Add {{ current_vip.name }} resource agent if not in skip list
when: current_vip.name not in ipsec_skip_networks
block:
- name: Was the {{ resource_agent_name }} Resource Agent added already?
command: pcs resource show {{ resource_agent_name }}
ignore_errors: yes
register: found_resource_agent
changed_when: found_resource_agent|failed
- name: Delete {{ resource_agent_name }} Resource Agent
command: pcs resource delete {{ resource_agent_name }}
when:
- 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 }} fallbacktunnel={{ fallback_tunnel }} --disabled
when:
- 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:
- resource_agent.changed or found_resource_agent|failed
- name: Add ordering rule with VIP ( {{ resource_agent_name }} ) for start operation
command: pcs constraint order start ip-{{ specific_vip }} then start {{ resource_agent_name }} symmetrical=false
when:
- resource_agent.changed or found_resource_agent|failed
- name: Add ordering rule with VIP ( {{ resource_agent_name }} ) for stop operation
command: pcs constraint order stop ip-{{ specific_vip }} then stop {{ resource_agent_name }} symmetrical=false
when:
- resource_agent.changed or found_resource_agent|failed
- name: Enable {{ resource_agent_name }} resource agent
command: pcs resource enable {{ resource_agent_name }}
when:
- resource_agent.changed or found_resource_agent|failed