TL;DR: Add the rundeck user to the sudoers and then use
Installing rundeck on Ubuntu usually results in creating a
rundeck user. We had a bunch of issues creating a rundeck job because we needed to execute a command as a specific user (only that user had access to some resources). Unfortunately, rundeck is not as versatile as Jenkins (plugins and such) — or I couldn’t find anything relevant at the time.
Initially, I’ve tried adding the rundeck user to the same group as the other user, but only with limited success. So, in order to make things clear, I’ve decided to add the rundeck user to the list of users capable of executing the
(root)# usermod -aG sudo rundeck
You can go a step further and make the
sudo -u myuser run a command without password.
Then, I could run a command as the other user:
export https_proxy=http://proxy.server:8010 && \
cd /home/myuser/dev && \
sudo mvn clean && \
whoami && \
sudo -u myuser mvn deploy
whoami would give me rundeck and the last command would execute nicely as the desired user.
A little experiment: If you find this post and ad below useful, please check the ad out :-)