Logging via terminal I can switch to root user fine:
ubuntu@ip-10-0-0-70:~$ sudo -s
root@ip-10-0-0-70:~# whoami
root
So I created in rundeck a job script with this:
whoami;
echo "1st step";
sudo -s;
echo "2nd step";
And when I run this, it prints:
ubuntu
1st step
After print '1st step' it get stucked forever. Seems a problem with sudo -s
command.
sudo -i
but the same happenssudo su - root
but the same happensany idea to switch to root in rundeck script?
This is the expected behaviour. You are running a shell via 'sudo -s' and then not leaving/exiting it ! So it waits forever for somethig that won't come.
You can probably add 'sudo' as an Advanced option of your script (where it says "Run script with an interpreter or prefix. E.g.: sudo, time:"). But it will run your whole script as root. If you just want a specific command to be run as root , just prefix your command with sudo as so:
sudo "enter_your_command_to_be_run_as_root_here"