# Managed by Ansible
# Collection: community.sap_install
# Role: sap_ha_set_hana
#
# Description: 
#  The following are sudo entries which are required for the pacemaker cluster
#  to update the SAP HANA cluster resource status.

{% for node in sap_ha_set_hana_cluster_nodes %}
Cmnd_Alias {{ node.hana_site }}_SOK = /usr/sbin/crm_attribute -n hana_{{ sap_ha_set_hana_sid | lower }}_site_srHook_{{ node.hana_site }} -v SOK -t crm_config -s SAPHanaSR
Cmnd_Alias {{ node.hana_site }}_SFAIL = /usr/sbin/crm_attribute -n hana_{{ sap_ha_set_hana_sid | lower }}_site_srHook_{{ node.hana_site }} -v SFAIL -t crm_config -s SAPHanaSR
{% endfor %}

{{ sap_ha_set_hana_sid|lower }}adm ALL=(ALL) NOPASSWD: {% for node in sap_ha_set_hana_cluster_nodes %}{{ node.hana_site }}_SOK, {{ node.hana_site }}_SFAIL{{ ", " if not loop.last else "" }}{% endfor %}

Defaults!{% for node in sap_ha_set_hana_cluster_nodes %}{{ node.hana_site }}_SOK, {{ node.hana_site }}_SFAIL{{ ", " if not loop.last else "" }}{% endfor %} !requiretty
