Writing a task to run an install script and normally it would have to be run with : sudo ./install.sh
My task looks like:
- name: Run the installer
shell: "{{ tempdir_output.path }}/device_manager_osx*/install.sh"
become: true
become_method: sudo
become_user: jenkins
when: dm_version.stdout != device_manager_version
The error I am getting is:
TASK [Run the installer] **************************************************************************************************************
fatal: [mac-station-xx.firmware.xxxxxxx.com]: FAILED! => {"changed": true, "cmd": "/var/folders/l7/wjqfy72x1p7dd2d11qt6s_6h0000gp/T/ansible.ZuX4_Ttemp/device_manager_osx*/install.sh", "delta": "0:00:00.073814", "end": "2019-04-19 20:47:38.723407", "msg": "non-zero return code", "rc": 1, "start": "2019-04-19 20:47:38.649593", "stderr": "", "stderr_lines": [], "stdout": "ERROR: This script needs to be run as root.\nExample- sudo install.sh", "stdout_lines": ["ERROR: This script needs to be run as root.", "Example- sudo install.sh"]}
I have tried:
Using just
become: true
to just get root permissions, but then the installer fails because it has to be installed under the jenkins user.Adding sudo in the shell ansible code block didn't work, it threw an error and said to use become methods.
Would appreciate any insight!