Using log filter key value data from step1 in step 2 node filter

73 views
Skip to first unread message

Chad Knudtson

unread,
Jan 4, 2022, 1:38:23 PM1/4/22
to rundeck-discuss
Is it possible to use the key value data collected in step 1 which is a local command line script as the value for the node filter in step 2 which will be executed on a remote server?  So step 1 is collecting the name of the node which step2 needs to execute against.

rac...@rundeck.com

unread,
Jan 4, 2022, 2:18:08 PM1/4/22
to rundeck-discuss

Hi Chad,

Step 2 should be a job reference step and pass the data variable to the filter step, let me post an example:

JobA (that collects the data variable and then calls the JobB using the Job Reference Step).

- defaultTab: nodes
  description: ''
  executionEnabled: true
  id: 6d178059-3d96-4b84-9fa5-1226d2dbe938
  loglevel: INFO
  name: JobA
  nodeFilterEditable: false
  plugins:
    ExecutionLifecycle: null
  scheduleEnabled: true
  sequence:
    commands:
    - description: generate the data and capture using key/value filter
      exec: echo "mynodefilter=node00"
      plugins:
        LogFilter:
        - config:
            invalidKeyPattern: \s|\$|\{|\}|\\
            logData: 'true'
            regex: (.*)=(.*)
          type: key-value-data
    - description: now dispatch the another job to specific node using the data variable
        captured in the previous step
      jobref:
        group: ''
        name: JobB
        nodeStep: 'true'
        nodefilters:
          filter: 'name: ${data.mynodefilter}'
        uuid: 0505d649-7b40-438e-b40c-9223e3612a81
    keepgoing: false
    strategy: node-first
  uuid: 6d178059-3d96-4b84-9fa5-1226d2dbe938

JobB (just prints something on the node specified in the filter):

- defaultTab: nodes
  description: ''
  executionEnabled: true
  id: 0505d649-7b40-438e-b40c-9223e3612a81
  loglevel: INFO
  name: JobB
  nodeFilterEditable: false
  nodefilters:
    dispatch:
      excludePrecedence: true
      keepgoing: false
      rankOrder: ascending
      successOnEmptyNodeFilter: false
      threadcount: '1'
    filter: ''
  nodesSelectedByDefault: true
  plugins:
    ExecutionLifecycle: null
  scheduleEnabled: true
  sequence:
    commands:
    - description: just print something
      exec: echo "hello world!"
    keepgoing: false
    strategy: node-first
  uuid: 0505d649-7b40-438e-b40c-9223e3612a81

See the result here.

So, here you can learn more about the job reference step.

And here is a basic example of key/value data values variables.

Hope it helps!

Chad Knudtson

unread,
Jan 5, 2022, 5:44:41 PM1/5/22
to rundeck-discuss
Worked exactly as I wanted it to.  thank you.
Reply all
Reply to author
Forward
0 new messages