Passing node attributes to the scripts

1,644 views
Skip to first unread message

Ben Gordon

unread,
Jul 30, 2013, 8:40:30 PM7/30/13
to rundeck...@googlegroups.com
Hi,

Within a job I'm trying to run another job (subjob) and pass arguments.  It works fine when passing arguments like ${option.attribute}, but fails when passing arguments ${node.attribute}, e.g. -hostname ${node.username}.
If just prior to calling the subjob, I run a command "echo ${node.username}", it displays what I expect, the value from the resourcse.xml file against the node and the key "username".  However, when running the same command in the subjob, i.e. "echo ${node.username}", it displays "${node.username}".  It doesn't pass the value.  I have tried various alternatives, quotes, multiple quotes, @node.username@, etc, but to no avail.

Does anyone have a solution or is this a bug or by design?

Ben

Greg Schueler

unread,
Jul 30, 2013, 8:47:54 PM7/30/13
to rundeck...@googlegroups.com, rundeck...@googlegroups.com
Hi Ben,

Job references don't execute in a node context, so node attributes are not available for the arguments to the job. 

-- 
Greg
--
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/groups/opt_out.
 
 

Ben Gordon

unread,
Jul 30, 2013, 10:19:54 PM7/30/13
to rundeck...@googlegroups.com
Hi Greg,

Thanks for your super quick reply.

So it is by design.  That is a pitty, it would be nice if it worked.

Ben

Guido Bakker

unread,
Jul 31, 2013, 4:12:43 AM7/31/13
to rundeck...@googlegroups.com
Hi Greg,

Is this something that will be implemented? Having job references in a node context would really simplify our job workflow.

Regards,
Guido

Jason Hartnell

unread,
Aug 26, 2013, 8:08:26 PM8/26/13
to rundeck...@googlegroups.com
Before the job reference is executed, shouldn't rundeck evaluate the variables being passed to the job reference?

This would be handy for building up a library of jobs that you may want to execute against specific nodes within parent workflow steps.

Greg Schueler

unread,
Aug 26, 2013, 9:12:19 PM8/26/13
to Jason Hartnell, rundeck...@googlegroups.com
Hi All,

FYI: in Rundeck 1.6.1 we re-enabled the by-node functionality for Job References.  It is now an explicit flag to use this mode, since the default is to run the once in a workflow.  You can set a Job Reference to operate as a Node Step or Workflow Step.  (In jobs.xml this becomes nodeStep="true" in the <jobref> element)

When "Node Step" is checked for a Job Reference, it will not execute once per-node in the parent job.  You can pass the node attributes to the job reference in the argument string using ${node.name}, etc.

If you are migrating jobs from Rundeck 1.4 (where this was the default behavior for Job References), you should be able to do a simple find/replace on the jobs.xml output, before importing in 1.6.1. e.g:

perl -i.orig -lp -e 's/jobref /jobref nodeStep="true" /g' jobs.xml

--
Greg Schueler
Reply all
Reply to author
Forward
0 new messages