简体   繁体   中英

Rundeck - run job on localhost as different user

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 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.

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

ie

[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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM