Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance /etc/sudoers.d/HanaSystemReplication #305

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions ansible/playbooks/sap-hana-system-replication-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
- {'section': 'ha_dr_provider_SAPHanaSR', 'key': 'execution_order', 'value': '1'}
- {'section': 'trace', 'key': 'ha_dr_saphanasr', 'value': 'info'}

- name: Add hooks into sudoers
- name: Add hooks into sudoers (SAPHanaSR-ScaleUp entries for writing srHook cluster attribute)
ansible.builtin.lineinfile:
path: /etc/sudoers.d/HanaSystemReplication
state: present
Expand All @@ -97,4 +97,20 @@
- {'regexp': '^Cmnd_Alias SFAIL_SITEA ', 'line': 'Cmnd_Alias SFAIL_SITEA = /usr/sbin/crm_attribute -n hana_{{ sap_hana_install_sid | lower }}_site_srHook_{{ primary_site }} -v SFAIL -t crm_config -s SAPHanaSR'}
- {'regexp': '^Cmnd_Alias SOK_SITEB', 'line': 'Cmnd_Alias SOK_SITEB = /usr/sbin/crm_attribute -n hana_{{ sap_hana_install_sid | lower }}_site_srHook_{{ secondary_site }} -v SOK -t crm_config -s SAPHanaSR'}
- {'regexp': '^Cmnd_Alias SFAIL_SITEB', 'line': 'Cmnd_Alias SFAIL_SITEB = /usr/sbin/crm_attribute -n hana_{{ sap_hana_install_sid | lower }}_site_srHook_{{ secondary_site }} -v SFAIL -t crm_config -s SAPHanaSR'}
- {'regexp': '^{{ sap_hana_install_sid | lower }}adm ALL=(ALL) NOPASSWD', 'line': '{{ sap_hana_install_sid | lower }}adm ALL=(ALL) NOPASSWD: SOK_SITEA, SFAIL_SITEA, SOK_SITEB, SFAIL_SITEB'}
- {'regexp': '^Cmnd_Alias HOOK_HELPER', 'line': 'Cmnd_Alias HOOK_HELPER = /usr/sbin/SAPHanaSR-hookHelper --sid={{ sap_hana_install_sid | upper }} --case=checkTakeover'}
- {'regexp': '^{{ sap_hana_install_sid | lower }}adm ALL=(ALL) NOPASSWD', 'line': '{{ sap_hana_install_sid | lower }}adm ALL=(ALL) NOPASSWD: SOK_SITEA, SFAIL_SITEA, SOK_SITEB, SFAIL_SITEB, HOOK_HELPER'}
when: 0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can add, in the vars: section, something like

vars:
    use_restrictive_sudoer_hooks: true

Then use use_restrictive_sudoer_hooks for the when fields


- name: Add hooks into sudoers (SAPHanaSR-ScaleUp entries for writing srHook cluster attribute and SAPHanaSR-hookHelper)
ansible.builtin.lineinfile:
path: /etc/sudoers.d/HanaSystemReplication
state: present
regexp: "{{ item.regexp }}"
line: "{{ item.line }}"
validate: /usr/sbin/visudo -cf %s
create: true
mode: '0440'
loop:
- {'regexp': '^{{ sap_hana_install_sid | lower }}adm ALL=(ALL) NOPASSWD', 'line': '{{ sap_hana_install_sid | lower }}adm ALL=(ALL) NOPASSWD: /usr/sbin/crm_attribute -n hana_{{ sap_hana_install_sid | lower }}_site_srHook_*'}
- {'regexp': '^{{ sap_hana_install_sid | lower }}adm ALL=(ALL) NOPASSWD', 'line': '{{ sap_hana_install_sid | lower }}adm ALL=(ALL) NOPASSWD: /usr/sbin/SAPHanaSR-hookHelper *'}
when: 1
Loading