calling another job from a .json file? or defining a job in a .json file?

628 views
Skip to first unread message

Aristos Vasiliou

unread,
Dec 10, 2018, 1:38:54 AM12/10/18
to rundeck-discuss
I have a job, with option2 picking up it's values from option1 .json file.
This is option2 remote values url
file:/var/rundeck/projects/project1/${option.services.value}
and this is option1 .json file. (services.json)
[
 
{"name":"service1", "value":"service1.json"},
 
{"name":"service2", "value":"service2.json"},
 
{"name":"service3", "value":"service3.json"},
 
{"name":"service4", "value":"service4.json"},
 
{"name":"service5", "value":"service5.json"},
 
{"name":"service6", "value":"service6.json"}
]
if someone selects "service6", I want to give them the option to enter a website URL

How can I do that?
What must "service6.json" file contain?
Or can I call an existing job that already does this?

Thank you

rac...@rundeck.com

unread,
Dec 10, 2018, 8:43:04 AM12/10/18
to rundeck-discuss
Hi Aristos,

You can use job reference with options using cascade like parameter, I did make this example for understanding it:

1) We create the first job with option "OperatingSystem" that print "The Operating System is: " and print the option that works with the other job using Cascade Options using job reference :-)

<joblist>
 
<job>
   
<context>
     
<options preserveOrder='true'>
       
<option name='OperatingSystem' value='OS' />
     
</options>
   
</context>
   
<defaultTab>summary</defaultTab>
   
<description></description>
   
<executionEnabled>true</executionEnabled>
   
<id>c8eae7ae-f96c-4bc2-93ac-9bc407674c63</id>
   
<loglevel>INFO</loglevel>
   
<name>JobEcho</name>
   
<nodeFilterEditable>false</nodeFilterEditable>
   
<scheduleEnabled>true</scheduleEnabled>
   
<sequence keepgoing='false' strategy='node-first'>
     
<command>
       
<exec>echo "The Operating System is ${option.OperatingSystem}"</exec>
     
</command>
   
</sequence>
   
<uuid>c8eae7ae-f96c-4bc2-93ac-9bc407674c63</uuid>
 
</job>
</joblist>

2) We create a second job with two cascade option: "main" and "os", this job call the first using job reference and passing the second option using the parameter "-Operating System ${option.OS}":

<joblist>
 
<job>
   
<context>
     
<options preserveOrder='true'>
       
<option enforcedvalues='true' name='family' required='true' valuesUrl='file:/home/user/Rundeck-3.0.9/projects/ProjectOPTIONS/json/os.json' />
       
<option enforcedvalues='true' name='OS' valuesUrl='file:/home/user/Rundeck-3.0.9/projects/ProjectOPTIONS/json/${option.family.value}' />
     
</options>
   
</context>
   
<defaultTab>summary</defaultTab>
   
<description></description>
   
<executionEnabled>true</executionEnabled>
   
<id>2f7da0a7-af0c-415a-9ae6-79fbb19a81da</id>
   
<loglevel>INFO</loglevel>
   
<name>JobCascadaOptions</name>
   
<nodeFilterEditable>false</nodeFilterEditable>
   
<scheduleEnabled>true</scheduleEnabled>
   
<sequence keepgoing='false' strategy='node-first'>
     
<command>
       
<jobref name='JobEcho'>
         
<arg line='-OperatingSystem ${option.OS}' />
         
<uuid>c8eae7ae-f96c-4bc2-93ac-9bc407674c63</uuid>
       
</jobref>
     
</command>
   
</sequence>
   
<uuid>2f7da0a7-af0c-415a-9ae6-79fbb19a81da</uuid>
 
</job>
</joblist>

This job needs this JSON files:

os.json:

[
   
{"name":"Linux", "value":"linux.json"},
   
{"name":"Windows",  "value":"windows.json"}
]

linux.json:

[
   
{"name":"Fedora", "value":"fedora"},
   
{"name":"Ubuntu",  "value":"ubuntu"}
]

windows.json:

[
   
{"name":"Windows Server 2012", "value":"win2012"},
   
{"name":"Windoes Server 2016",  "value":"win2016"}
]

Hope it helps!

Aristos Vasiliou

unread,
Dec 10, 2018, 12:07:28 PM12/10/18
to rundeck-discuss
Thanks for your reply. Please bare with me as I'm trying to understand this.
I need to somehow allow someone to define a website URL when they select the "browser" option.

2018-12-10 19_04_04-Rundeck - JobSelection.png



shops.json
[
 
{"name":"shop1", "value":"services.json"},
 
{"name":"shop2", "value":"services.json"},
 
{"name":"shop3", "value":"services.json"}
]

services.json
[
 
{"name":"audio", "value":"audio"},
 
{"name":"video", "value":"video"},
 
{"name":"stream", "value":"stream"},
 
{"name":"youtube", "value":"youtube"},
 
{"name":"browser", "value":"browser"}
]

job definition
<joblist>
 
<job>
   
<context>
     
<options preserveOrder='true'>

       
<option enforcedvalues='true' name='services' required='true' valuesUrl='file:/var/rundeck/projects/BeatBox/${option.shops.value}'>
         
<label>services</label>
       
</option>
       
<option enforcedvalues='true' name='shops' required='true' valuesUrl='file:/var/rundeck/projects/BeatBox/shops.json'>
         
<label>shops</label>
       
</option>
       
<option name='website'>
         
<label>website</label>
       
</option>
     
</options>
   
</context>
   
<defaultTab>output</defaultTab>
   
<description></description>
   
<dispatch>
     
<excludePrecedence>true</excludePrecedence>
     
<keepgoing>true</keepgoing>
     
<rankOrder>ascending</rankOrder>
     
<successOnEmptyNodeFilter>true</successOnEmptyNodeFilter>
     
<threadcount>1</threadcount>
   
</dispatch>
   
<executionEnabled>true</executionEnabled>
   
<group>Administration</group>
   
<id>52bc9f80-0f80-4469-ac8d-885403f1af0b</id>
   
<loglevel>INFO</loglevel>
   
<name>JobSelection</name>
   
<nodeFilterEditable>false</nodeFilterEditable>
   
<nodefilters>
     
<filter>.*</filter>
   
</nodefilters>
   
<nodesSelectedByDefault>true</nodesSelectedByDefault>

   
<scheduleEnabled>true</scheduleEnabled>
   
<sequence keepgoing='false' strategy='node-first'>
     
<command>

       
<exec>echo @option.shops@</exec>
     
</command>
   
</sequence>
   
<uuid>52bc9f80-0f80-4469-ac8d-885403f1af0b</uuid>
 
</job>
</joblist>

rac...@rundeck.com

unread,
Dec 10, 2018, 4:37:40 PM12/10/18
to rundeck-discuss
Hi Aristos,

A good option is adding a JSON file for each option (video, stream, youtube, and audio and browser) this can be made with some options or one option if you like.

shops.json:

[
 
{"name":"shop1", "value":"services.json"},
 
{"name":"shop2", "value":"services.json"},
 
{"name":"shop3", "value":"services.json"}
]

services.json:

[
 
{"name":"audio", "value":"audio.json"},
 
{"name":"video", "value":"video.json"},
 
{"name":"stream", "value":"stream.json"},
 
{"name":"youtube", "value":"youtube.json"},
 
{"name":"browser", "value":"browser.json"}
]

audio.json:

[
 
{"name":"lastfm", "value":"Last.fm"},
 
{"name":"tunein", "value":"TuneIn"}
]

video.json:

[
 
{"name":"vimeo", "value":"Vimeo"},
 
{"name":"dailymotion", "value":"Dailymotion"}
]

stream.json:

[
 
{"name":"younow", "value":"YouNow"},
 
{"name":"twitch", "value":"Twitch.tv"}
]

youtube.json:

[
 
{"name":"yt1", "value":"my yt channel 1"},
 
{"name":"yt2", "value":"my yt channel 2"}
]

And specifically for brower.json, create a JSON like:

[
 
{"name":"specify", "value":"please specify here", "selected":"true"}
]

Now, in the third option of your job definition, you can select "Restriction: None" for edit this field in case that needs. Use this example please and play with him :-)

<joblist>
 
<job>
   
<context>
     
<options preserveOrder='true'>

       
<option enforcedvalues='true' name='Shop' valuesUrl='file:/home/user/Rundeck-3.0.9/projects/ProjectOPTIONS/json/shops.json' />
       
<option enforcedvalues='true' name='Services' valuesUrl='file:/home/user/Rundeck-3.0.9/projects/ProjectOPTIONS/json/${option.Shop.value}' />
       
<option name='website' required='true' valuesUrl='file:/home/user/Rundeck-3.0.9/projects/ProjectOPTIONS/json/${option.Services.value}' />

     
</options>
   
</context>
   
<defaultTab>summary</defaultTab>
   
<description></description>
   
<executionEnabled>true</executionEnabled>

   
<id>ed0d84fe-135b-41ee-95b6-6daeaa94894b</id>
   
<loglevel>INFO</loglevel>
   
<name>ServicesJSON</name>

   
<nodeFilterEditable>false</nodeFilterEditable>
   
<scheduleEnabled>true</scheduleEnabled>
   
<sequence keepgoing='false' strategy='node-first'>
     
<command>

       
<exec>echo ${option.website}</exec>
     
</command>
   
</sequence>
   
<uuid>ed0d84fe-135b-41ee-95b6-6daeaa94894b</uuid>
 
</job>
</joblist>

The job looks like:

Screenshot_2018-12-10_18-20-45.png


Hope it helps!
Reply all
Reply to author
Forward
0 new messages