4

I'm quite new to Rundeck and is evaluating it as alternate to Jenkins to run our adhoc operational tasks.

We have all commands & scripts on the Rundeck server that needs to be run as specific user, eg.: ubuntu.

I tried change configurations at some places like /etc/rundeck/framework.properties (framework.ssh.user=ubuntu) and /var/rundeck/projects/myproject/etc/resources.xml (set username="ubuntu" for localhost node) but my job anyway always run as user 'rundeck', that's quite frustrating as at first I thought it should be simple to achieve that.

So, am I missing something or Rundeck cannot run script locally as different user to 'rundeck'?

UPDATE: I found one solution for now, that's to use the Script step then in the advance option Invocation String I can set like "sudo -u ubuntu" to that so my script runs as ubuntu from rundeck.

However it's still not really convenient for using that sudo, for example environment variables preserving issue.

Arcobaleno
  • 484
  • 1
  • 5
  • 14
  • Can you make the script run itself with the desired users? – Fabio Jul 29 '16 at 13:11
  • @Fabio actually we have to run it as 'ubuntu' for compatibility with other tools & frameworks we're using. We have lots of scripts or commands that might invoke to other tools - that making them all need to switch to ubuntu themselves quite not an option for us right now. – Arcobaleno Jul 29 '16 at 13:25
  • What about having a single script that runs other scripts as Ubuntu? You can pass the original script(s) as the first argument, and the other arguments as the following ones. Is that more realistic? – Fabio Jul 29 '16 at 13:29

2 Answers2

0

@Arcobaleno you will have to dispatch to the rundeck server to use the ssh setup. The "Local Command" or a Command step not dispatched uses the Local Node Executor which is a plugin point. You could create a Local Node executor to implicitly sudo to the user you want and run the command.

  • Can you tell more specific as this is quite new to me, I tried with Command, Script, Local Command and also try run a command on target node (localhost) in the Commands tab and seems none of them uses my SSH config, is any of them the Local Node Executor you mentioned? If not how I can create Local Node Executor? – Arcobaleno Jul 30 '16 at 04:58
0

You need to ssh from you localhost to your localhost(pretend localhost as a remote server).

i.e.

[ubuntu]$ ssh ubuntu@xx.xx with passwordless ssh. 

Copy id_rsa.pub to ~/.ssh/authorized_keys. (The id_ras.pub is stored in the default place /var/lib/rundeck/.ssh/id_rsa.pub.).

Then you can run your program using your ubuntu env.

This works for me.

aircraft
  • 25,146
  • 28
  • 91
  • 166
Jake
  • 1