Passing Options into a python script file

1,276 views
Skip to first unread message

David Grantham

unread,
Sep 15, 2017, 7:02:52 PM9/15/17
to rundeck-discuss
I have a set of option check boxes that im trying to pass into my script. 

It seems that i can do this with a inline script but my use case subjects me to using a local script file. (note that if i write the same script below in bash using $RD_OPTION_REGIONS i get the correct value)

This is the contents of my script.

#!/usr/bin/env python
print '@{option.Regions}@'

When i run it rundeck returns this..

16:46:58localhost 1. File@{option.Regions}@

kristia...@gooddata.com

unread,
Sep 18, 2017, 3:14:22 AM9/18/17
to rundeck-discuss
Hello,

since $RD_OPTION_REGIONS works in a bash script, I think Rundeck passes the arguments to the script as environment variables. You can therefore parse them in a Python script:

#!/usr/bin/env python
import os
print os.environ['RD_OPTION_REGIONS']

Best regards
Kristian Lesko




Greg Schueler

unread,
Sep 18, 2017, 12:26:16 PM9/18/17
to rundeck-discuss
The syntax for Inline Scripts is @option.Regions@

For local script files, the inline syntax is not available.  You can use $RD_OPTION_REGIONS for the environment variable, or you can pass the value as an argument to the script as ${option.Regions}


--
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 post to this group, send email to rundeck...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rundeck-discuss/f7ee885c-bc83-41c6-a1cc-0adf55e79f91%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

David Grantham

unread,
Sep 18, 2017, 2:16:45 PM9/18/17
to rundeck-discuss
This saved me thanks!
Reply all
Reply to author
Forward
0 new messages