sap-hana icon indicating copy to clipboard operation
sap-hana copied to clipboard

Backlog: use become_flags to set the right shell for sidadm

Open rukawata opened this issue 5 years ago • 0 comments

Problem statement Currently we have to source ~/.bashrc before each shell command that uses become user sidadm

Enhancement Will set bash for become user

Notes The reason for that is HANA brings it's own python lib. The solution is to always use the HANA python interpret if it exists. Once we identify the python interpreter from HANA installation, use that for the roles/tasks that uses sidadm.

Sample:

- hosts: hanadbnodes
  vars:
    ansible_python_interpreter: /usr/sap/RU1/HDB01/exe/Python/bin/python
  tasks:
    - name: test sidadm
      shell:
        HDB version
      become: yes
      become_method: su
      become_user: ru1adm
      become_flags: '--login'

Sample output:

azureadm@rti-a:~$ ansible-playbook -i hosts_1 test.yml -v
No config file found; using defaults

PLAY [hanadbnodes] ********************************************************************************************************

TASK [Gathering Facts] ****************************************************************************************************
ok: [10.1.2.4]

TASK [test sidadm] ********************************************************************************************************
changed: [10.1.2.4] => {"changed": true, "cmd": "HDB version", "delta": "0:00:01.001199", "end": "2020-04-05 20:53:34.871068", "rc": 0, "start": "2020-04-05 20:53:33.869869", "stderr": "", "stderr_lines": [], "stdout": "HDB version info:\n  version:             2.00.040.00.1553674765\n  branch:              fa/hana2sp04\n  machine config:      linuxx86_64\n  git hash:            c8210ee40a82860643f1874a2bf4ffb67a7b2add\n  git merge time:      2019-03-27 09:19:25\n  weekstone:           0000.00.0\n  cloud edition:       0000.00.00\n  compile date:        2019-03-27 09:30:26\n  compile host:        ld4551\n  compile type:        rel", "stdout_lines": ["HDB version info:", "  version:             2.00.040.00.1553674765", "  branch:              fa/hana2sp04", "  machine config:      linuxx86_64", "  git hash:            c8210ee40a82860643f1874a2bf4ffb67a7b2add", "  git merge time:      2019-03-27 09:19:25", "  weekstone:           0000.00.0", "  cloud edition:       0000.00.00", "  compile date:        2019-03-27 09:30:26", "  compile host:        ld4551", "  compile type:        rel"]}

PLAY RECAP ****************************************************************************************************************
10.1.2.4                   : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

Dependencies

Checklist

  • [ ] Add ansible_become_pass into hosts file (done by TF)
  • [ ] With some of the installations, one have to add sudo user into sapsys group - this can be a pre-check task
  • [ ] do user escalation at higher level with become_flags
  • [ ] remove source ~/.bashrc

rukawata avatar Apr 03 '20 16:04 rukawata