prompt user for information before running job

665 views
Skip to first unread message

Aristos Vasiliou

unread,
Jan 12, 2017, 12:22:15 PM1/12/17
to rundeck-discuss

I want to set up a rundeck job, to modify a URL in a file. I need a way for the user to be able to input the url before executing the job. This is how I'm doing it now, through the terminal. But I need a way through rundeck for the user to be able to define the www.new-url.com


sed -i "s/www.old-url.com/www.new-url.com/g" /home/user/url.sh


I read this http://rundeck.org/docs/manual/jobs.html#job-options I'm having some trouble, because I want to force the user to enter a URL, and I can only force the user by defining Allowed Values or by Matching Regular Expression. 


This limits the user from entering any URL they want. Any suggestions?


Jason McIntosh

unread,
Jan 12, 2017, 6:16:33 PM1/12/17
to rundeck-discuss
I'm starting to test with consul as an orchestration engine.  E.g. add a step that might do the following

#!/bin/bash
STATUS=1
while [ $STATUS != 0 ]; do
 curl -s localhost:8500/v1/kv/$1/url?raw
 STATUS=$?
 if [[ $STATUS != 0 ]]; then
   echo "Still waiting upon URL"
   sleep 5
 fi
done
 curl -X DELETE localhost:8500/v1/kv/$1/url

This is pretty rough but gets the concept there...
Jason

Aristos Vasiliou

unread,
Jan 12, 2017, 11:18:01 PM1/12/17
to rundeck-discuss
Thanks for the reply.
Can you explain how this works? I'm new to rundeck, and I though this would be something I could configure from the web interface. How is your bash script working with the web interface, to prompt the user to enter the url?
thanks

Fred Ellenberger

unread,
Jan 12, 2017, 11:50:02 PM1/12/17
to rundeck...@googlegroups.com
It is not sufficient enough to just make the option required and let the user enter what they want?  What kind of validation do you expect to ensure it is a valid URL?  A check to determine if a Web Server Status is returned?

If so, you could always create an inline script step that executes some form of curl-based validation before performing your find/replace action.  That’s how I would approach this anyways if a validation check was necessary.

Also, there is an “HTTP Request” step plugin that might work for you to do some URL validation, however I have not tried it myself.

--
You received this message because you are subscribed to the Google Groups "rundeck-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rundeck-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rundeck-discuss/e9559aba-c8f6-4c80-b650-dcb4d94f1d88%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Aristos Vasiliou

unread,
Jan 13, 2017, 12:27:07 AM1/13/17
to rundeck-discuss
Yes, its sufficient to make the option required. The user can enter any text they want. But they do have to enter something. I was simply asking how can I use the bash script you provided, with rundeck, to give the option to the user, to enter a url.

Jason McIntosh

unread,
Jan 13, 2017, 1:14:04 AM1/13/17
to rundeck...@googlegroups.com
IF you want it before the job even starts, querying a remote system to do so is one method.  However, if you can do it as part of the job, that's likely much easier/faster/safer/cleaner/etc.  The method would be to use the regular expression validator against the user input, if you want to allow it to be a URL.  Not so simple regular expressions:


BUT that should work.  It's that or query a database table, cat a file, etc. to get the user input.  I used consul as an example as i'm playing with consul stuff.


To unsubscribe from this group and stop receiving emails from it, send an email to rundeck-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rundeck-discuss/f627314f-fbf5-44c7-bf4e-bfe3c1b7ab0c%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Aristos Vasiliou

unread,
Jan 13, 2017, 3:50:45 AM1/13/17
to rundeck-discuss
I don't know if I'm being clear on what I want to achieve.

I have a job configured in rundeck. When a user tries to run this job he should get a prompt to enter a URL. I don't want to validate if the user entered a URL. If they put something else in the prompt its their problem.
This URL should be part of this command "sed -i "s/www.old-url.com/this_is_where_i _want_to_put_the_url_the_user_specified/g" /home/user/url.sh" which will be sent to the node. (the command is part of the rundeck job)

How can I achieve this?
Thanks

Gmail

unread,
Jan 13, 2017, 10:35:48 AM1/13/17
to rundeck...@googlegroups.com
Create a job option, let's say the name is "url".

Now, in your inline script step, you can make reference to the value of this option using @option.url@

There are other ways to reference the option value (I.e $RD_OPTION_URL), depending on where you are trying to use it, so just review the doc on job options for further info. Hope this helps.

-Fred
Reply all
Reply to author
Forward
0 new messages