how to set the value option when I use a json file with array of maps

2,828 views
Skip to first unread message

Levent Tutar

unread,
Mar 10, 2014, 11:02:06 AM3/10/14
to rundeck...@googlegroups.com
Hi,

I am using rundeck 2.0.1.

I defined an option name "test_type" as remote URL "file:/tmp/levent/options/test_types.json".

The content of the file is:
[rundeck@rundeck options]$ cat test_types.json
{"test_type": "levent", "test_version": "1.3", "test_directory": "/tmp"}


According to http://rundeck.org/docs/manual/jobs.html#json-format, I get "If a simple object or name/value pairs are returned, then the name will be displayed in the list, but the value will be used as the input." This is working as seen in the attachment. I get an empty list and I can choose of the keys from the drop-down box.

When I try to set the value of test_type to test_version, I can not get this working.

I tried:
file:/tmp/levent/options/test_types.json/test_version
file:/tmp/levent/options/test_types.json?test_version
etc.

How can I do this?

the idea behind:
All of the jobs will use this json file as a wallet in order to pass information to each other. Instead of using small atomic json files, I want to use one json file.

Thank you in advance.


GrabberRaster 0506.jpg
GrabberRaster 0507.jpg
GrabberRaster 0508.jpg

Levent Tutar

unread,
Mar 11, 2014, 7:30:25 AM3/11/14
to rundeck...@googlegroups.com

Moses Lei

unread,
Mar 11, 2014, 1:01:38 PM3/11/14
to rundeck...@googlegroups.com
Levent, I'm not sure what using JSON for options and using a local JSON file as a data cache have to do with each other... can you be more clear about what you're trying to do?

For options, you're seeing the correct behavior: "test_version" is the key and 1.3 is the value, so it's setting it to 1.3. If you need a set of values for each option, you'll need a different local JSON file for each, or a cgi script which knows how to take a parameter and return different values. There's no way to use a URL to narrow the JSON field as you described in your post.

--
Moses Lei
Principal, Village Chime LLC
mobile: +1 703 901 5969 | skype: moseslei | yahoo: moseslei


--
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.
For more options, visit https://groups.google.com/d/optout.

Levent Tutar

unread,
Mar 11, 2014, 7:43:24 PM3/11/14
to rundeck...@googlegroups.com
Hi Moses,

I want to enrich with each job the local JSON file instead of having several atomic json files.
job1: The file job.execid is created with the following content:
{"ip_address" : "123.123.123.123"}
job2: node value is added, as seen below. but I want to give the value of ip_address as input for this job.
{"ip_address" : "123.123.123.123","node":"prod113"}

That is why I was trying to set the value of file:/xxx with an ? or / . I am seeing the correct behaviour. But I get an empty list. I have to choose test_type of test_version. I can not define one of these as default value.

Kind regards,

Levent

Moses Lei

unread,
Mar 11, 2014, 8:02:08 PM3/11/14
to rundeck...@googlegroups.com
Oh, I see. You are trying to store persistent data between steps. This is not what the JSON option files are designed to do. They are designed to let the user choose between a set of available values (with optional descriptive names).

What you can do instead is to use a file in a standard location differentiated by execid, but simply load it inside the steps using code from inside the step. For example, if your file has pairs of key value pairs like NAME=value, you can source at the beginning of a bash script step to get them as variables. Or if your file has JSON data then you can use a json parser to get the information. But that functionality should be internal to the actual running code of the step.

Moses

--
Moses Lei
Principal, Village Chime LLC
mobile: +1 703 901 5969 | skype: moseslei | yahoo: moseslei


Levent Tutar

unread,
Mar 11, 2014, 8:12:39 PM3/11/14
to rundeck...@googlegroups.com
Hi Moses,

Thank you for your quick reply. If the JSON option files are not designed to do that, then I rest my case and keep using atomic JSON files.
I am now indeed using a standard differentiated by execid.
My json file name is the key and the content is just a list. For example the following JSON file contains the ip_address when the creat_vm job is run. (117 is job.execid)

[rundeck@rundeck 117]$ pwd
/tmp/levent/order/117
[rundeck@rundeck 117]$ cat ip_address_of_the_node.json
["123.123.111"]
[rundeck@rundeck 117]$ ls
ip_address_of_the_node.jsonĀ  os_type.json
[rundeck@rundeck 117]$

and indeed reading or writing the json files inside a step.

I only need to figure out the following:
See https://groups.google.com/forum/#!topic/rundeck-discuss/BQG7HfADPNk

I am very excited about Rundeck. It is a mature product. I started using it since last week and I am now almost able to give a demo.

Kind regards,

Levent
Reply all
Reply to author
Forward
0 new messages