We are currently running Rundeck 4.11 community version. We are having problems using aggregated log filter variables.
Example:
Job1 runs a command step against three nodes (Keep running if failed) The command returns one line of stdout per node.
Job1 has a log filter that captures all output from previous step.
Regex: ^(.*)$ Name: output
Job1 runs a global variable step that sets an exportable variable from previous variable, for all nodes.
all_output=${data.output*}
Job2 starts by running Job1 as a referenced job (using referenced nodes)
Job2 runs a command locally to print all output from the global variable set in Job1.
echo "${export.all_output}"
Expected behaviour: Comma separated list of all output (from all nodes) from the first step of Job1 regardless of state of job.
Examined behaviour:
If Job1-Step1 is successful on all nodes, all output is printed.
If Job1-Step1 is unsuccessful (rc > 0) on all nodes, all output is printed.
If some nodes fail on Job1-Step1 and some are successful, only failed nodes output is printed.
If rundeck can not connect to at least one node, only the literal text ${export.all_output} is printed, and variable is not expanded at all. Another run expanded the variable, but it was empty.
It seems that the global log filter, and use of data.output* (note the star), is dependent on the status of steps/jobs, and is not purely printing everything the log filter captures.
Here are two jobs that reproduce the issue. This basically runs a command on each node and exits randomly with 0 or 1. Only the failed nodes' data is captured. Just modify the filter so it will run in your environment.
- defaultTab: nodes
description: ''
executionEnabled: true
group: aggregate
id: 0d50e127-7017-4319-8b56-3fd56080e5a3
loglevel: INFO
name: test
nodeFilterEditable: false
nodefilters:
dispatch:
excludePrecedence: true
keepgoing: true
rankOrder: ascending
successOnEmptyNodeFilter: false
threadcount: '1'
filter: 'tags: linux'
nodesSelectedByDefault: true
plugins:
ExecutionLifecycle: null
scheduleEnabled: true
sequence:
commands:
- exec: ((RANDOM % 2)) && { echo "${node.name} OK"; exit 0; } || { echo "${node.name}
NOT OK"; exit 1; }
plugins:
LogFilter:
- config:
invalidKeyPattern: \s|\$|\{|\}|\\
logData: 'false'
name: full_command_output
regex: ^(.*)$
replaceFilteredResult: 'false'
type: key-value-data
- configuration:
export: aggregated_output
group: export
value: ${data.full_command_output*;}
nodeStep: false
type: export-var
keepgoing: true
strategy: node-first
uuid: 0d50e127-7017-4319-8b56-3fd56080e5a3
- defaultTab: nodes
description: ''
executionEnabled: true
group: aggregate
id: d888974d-7dee-4d55-9afa-fa529a0d968b
loglevel: INFO
name: aggtest
nodeFilterEditable: false
nodefilters:
dispatch:
excludePrecedence: true
keepgoing: false
rankOrder: ascending
successOnEmptyNodeFilter: false
threadcount: '1'
filter: MyServer
nodesSelectedByDefault: true
plugins:
ExecutionLifecycle: null
scheduleEnabled: true
sequence:
commands:
- jobref:
childNodes: true
group: aggregate
name: test
nodeStep: 'true'
uuid: 0d50e127-7017-4319-8b56-3fd56080e5a3
- configuration:
command: 'echo ''''''Aggregated Output: ${export.aggregated_output}'''''''
nodeStep: true
type: localexec
keepgoing: true
strategy: node-first
uuid: d888974d-7dee-4d55-9afa-fa529a0d968b
I'm seeing the same behavior on the latest Rundeck version, please report it here.
Anyway, I found a workaround using a temporary working file. Basically, is about replacing the export variable by an local file.
Let me share the jobs (tested on Rundeck 4.14.1).
Parent job:
Child job:
Check the result here.