Troubleshooting Key-Value Variable Transmission Issues in Rundeck Workflow Steps

57 views
Skip to first unread message

Andreas Manousakis

unread,
May 27, 2024, 9:25:47 AM5/27/24
to rundeck-discuss
Hello,

My case:
1. A parent job has 2 steps
2. In the 1st step a (Workflow) Job A calls (jobRef) ChildJob A as workflow step with a set of parameters (options)
3. ChildJob A is just a script that perform some functionality using the parameters(options) and prints the Key-Value data with "echo" commands. The response is like: "RUNDECK:DATA:a_key0=a_value0" (If I add "Log Filter" in the ChildJobA, the Key-Value Results data are correctly displayed as results)
4. In the 2nd step, a (Workflow) Job B calls (jobRef) ChildJob B with only one parameter (option), which is supposed to retrieve data from $data as key-value pairs (example: <arg line='-a.key01 ${data.a_key0}' />).
5. However, Step 4 never works as intended. Even adding an intermediate (node) script step and trying to hard code "RUNDECK:DATA:a_key0=a_value0" (i.e., echo "RUNDECK:DATA:a_key0=a_value0") doesn't transmit the data to Step 2, resulting in an exception.

So the issues are 2:
1. The Key-Value variables don't propagate from ChildJob A to Parent Job (Job A)
2. The Key-Value variables "RUNDECK:DATA:a_key0=a_value0"can't transmit from a Node to a Workflow step.

My workaround:
1. Since ChildJobA is a Bash script I exported the values to a temp file: echo "export a_key0=a_value0" >> /tmp/rundeck_vars.sh
2. In the Parent Job I added an intermediate (Nnode) script step to set the exported variables as global variables and then set them again as rundeck Key-Value variables:
            source /tmp/rundeck_vars.sh                                    
            echo "RUNDECK:DATA:a_key0=$a_value0"            
3) Added the nodeStep='true' param to Job B in order to get correclty the final <arg line='-a.key01 ${data.a_key0}' /> without any issues

Are there any other Rundeck-compliant methods to move variables around without resorting to confusing workarounds like the one described?

Note1: I am using a pretty old Rundeck version(3.0.10.20181220), with xml configurations, so please add this kind of examples if code response is required

Best regards,
Manousakis Andreas

This e-mail is subject to the following Legal Notice


rac...@rundeck.com

unread,
May 27, 2024, 12:49:27 PM5/27/24
to rundeck-discuss

Hi Andreas,

The Key-Value variables don’t propagate from ChildJob A to Parent Job (Job A)

To do so, you can “elevate” the data value from child to parent using the global variable step in the child job, I made a basic example:

Parent Job (it calls the child and then prints the global variable generated by the child job):

<joblist> <job> <defaultTab>nodes</defaultTab> <description></description> <executionEnabled>true</executionEnabled> <id>81fc6558-70eb-4e04-8839-056bbf78706f</id> <loglevel>INFO</loglevel> <name>ParentJob</name> <nodeFilterEditable>false</nodeFilterEditable> <plugins /> <scheduleEnabled>true</scheduleEnabled> <sequence keepgoing='false' strategy='node-first'> <command> <exec>echo "hi"</exec> </command> <command> <jobref name='ChildJob' nodeStep='true'> <uuid>29b24a20-b5db-47c8-bc62-f510d854e58c</uuid> </jobref> </command> <command> <exec>echo "I am the parent and this is the child data variable: ${export.myglobal}"</exec> </command> </sequence> <uuid>81fc6558-70eb-4e04-8839-056bbf78706f</uuid> </job> </joblist>

Child Job (generates a data value and then “elevates” that data to a global variable)

<joblist> <job> <defaultTab>nodes</defaultTab> <description></description> <executionEnabled>true</executionEnabled> <id>29b24a20-b5db-47c8-bc62-f510d854e58c</id> <loglevel>INFO</loglevel> <name>ChildJob</name> <nodeFilterEditable>false</nodeFilterEditable> <plugins /> <scheduleEnabled>true</scheduleEnabled> <sequence keepgoing='false' strategy='node-first'> <command> <exec>echo "mykey=myvalue"</exec> <plugins> <LogFilter type='key-value-data'> <config> <invalidKeyPattern>\s|\$|\{|\}|\\</invalidKeyPattern> <logData>true</logData> <regex>(.*)=(.*)</regex> <replaceFilteredResult>false</replaceFilteredResult> </config> </LogFilter> </plugins> </command> <command> <step-plugin type='export-var'> <configuration> <entry key='export' value='myglobal' /> <entry key='group' value='export' /> <entry key='value' value='${data.mykey*}' /> </configuration> </step-plugin> </command> <command> <exec>echo "I am the child, this is the global variable from data value: ${export.myglobal}"</exec> </command> </sequence> <uuid>29b24a20-b5db-47c8-bc62-f510d854e58c</uuid> </job> </joblist>

The Key-Value variables “RUNDECK:DATA:a_key0=a_value0”can’t transmit from a Node to a Workflow step.

Same, try "elevating" the data value as a global variable. I made two scenarios:

Doesn’t work:

<joblist> <job> <defaultTab>nodes</defaultTab> <description></description> <executionEnabled>true</executionEnabled> <id>7574de32-4bbf-4b7d-b880-bc34f3ec1595</id> <loglevel>INFO</loglevel> <name>TestVariables</name> <nodeFilterEditable>false</nodeFilterEditable> <plugins /> <scheduleEnabled>true</scheduleEnabled> <sequence keepgoing='false' strategy='node-first'> <command> <exec>echo "mykey=myvalue"</exec> <plugins> <LogFilter type='key-value-data'> <config> <invalidKeyPattern>\s|\$|\{|\}|\\</invalidKeyPattern> <logData>false</logData> <regex>(.*)=(.*)</regex> <replaceFilteredResult>false</replaceFilteredResult> </config> </LogFilter> </plugins> </command> <command> <exec>echo ${data.mykey}</exec> </command> <command> <jobref name='AnotherChild'> <arg line='-opt1 ${data.mykey}' /> <uuid>89c160d4-845a-403e-bd58-4bd9b95e8110</uuid> </jobref> </command> </sequence> <uuid>7574de32-4bbf-4b7d-b880-bc34f3ec1595</uuid> </job> </joblist>

It Works:

<joblist> <job> <defaultTab>nodes</defaultTab> <description></description> <executionEnabled>true</executionEnabled> <id>7574de32-4bbf-4b7d-b880-bc34f3ec1595</id> <loglevel>INFO</loglevel> <name>TestVariables</name> <nodeFilterEditable>false</nodeFilterEditable> <plugins /> <scheduleEnabled>true</scheduleEnabled> <sequence keepgoing='false' strategy='node-first'> <command> <exec>echo "mykey=myvalue"</exec> <plugins> <LogFilter type='key-value-data'> <config> <invalidKeyPattern>\s|\$|\{|\}|\\</invalidKeyPattern> <logData>false</logData> <regex>(.*)=(.*)</regex> <replaceFilteredResult>false</replaceFilteredResult> </config> </LogFilter> </plugins> </command> <command> <exec>echo ${data.mykey}</exec> </command> <command> <step-plugin type='export-var'> <configuration> <entry key='export' value='mywskey' /> <entry key='group' value='export' /> <entry key='value' value='${data.mykey*}' /> </configuration> </step-plugin> </command> <command> <jobref name='AnotherChild'> <arg line='-opt1 ${export.mywskey}' /> <uuid>89c160d4-845a-403e-bd58-4bd9b95e8110</uuid> </jobref> </command> </sequence> <uuid>7574de32-4bbf-4b7d-b880-bc34f3ec1595</uuid> </job> </joblist>

Hope it helps!

Regards.

Reply all
Reply to author
Forward
0 new messages