rundeck / rundeck

Enable Self-Service Operations: Give specific users access to your existing tools, services, and scripts

Home Page:http://rundeck.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inconsistency between local and remote execution with variable expansion on options using nested variables

Daryes opened this issue · comments

Describe the bug
simply the reopening of this bug #2698 & #7138 that still surprisingly exists as of today.

When using a option using as value the node or project context variable, like node.name,
the plugin "Command - Execute a remote command" won't expand the nested variables and will show a literal "${node.name}" or "${job.name}"
As opposite, using the plugin "Local Command - Run a command locally on the server" will have the nested variables expanded correctly.

Be it with nodes set to "Execute locally" or "dispatch to nodes"

My Rundeck detail

  • Rundeck version: 4.17.4 and 5.0.1
  • install type: deb
  • OS Name/version: ubuntu 22.04
  • DB Type/version: postgres

To Reproduce
Steps to reproduce the behavior:
load this job (reworked version) :

- defaultTab: nodes
  description: "Show the behavior difference with options between these execution\
    \ plugins :  \n\n* Command - Execute a remote command\n* Local Command - Run a\
    \ command locally on the server\n"
  executionEnabled: true
  group: bug
  id: e71ac287-ccee-4e10-8f8d-741779f191c1
  loglevel: INFO
  name: Inconsistency on expansion with nested variables in options
  nodeFilterEditable: false
  options:
  - name: TEST1
    value: ${node.name}
  - name: TEST2
    value: ${job.project}
  plugins:
    ExecutionLifecycle: null
  scheduleEnabled: true
  sequence:
    commands:
    - configuration:
        command: 'echo local - using nested options variables : ${option.TEST1} ${option.TEST2}'
      description: local - variable expansion
      nodeStep: true
      type: localexec
    - configuration:
        command: 'echo local - what is expected : ${node.name} ${job.project}'
      description: local - direct value
      nodeStep: true
      type: localexec
    - description: remote - variable expansion
      exec: 'echo remote - using nested options variables : ${option.TEST1} ${option.TEST2}'
    - description: remote - variable expansion unquoted
      exec: ' echo remote - using unquoted nested options variables : ${unquotedoption.TEST1}
        ${unquotedoption.TEST2}'
    - description: remote - direct value
      exec: 'echo remote - what is expected : ${node.name} ${job.project}'
    keepgoing: false
    strategy: node-first
  uuid: e71ac287-ccee-4e10-8f8d-741779f191c1

2 options are defined, with ${node.name} and ${job.project} as values.
The options are then called in each steps with a echo ${option.TEST1} ${option.TEST2}

Run the job, compare the output :

local - using nested options variables : localhost rundeck
local - what is expected : localhost rundeck
remote - using nested options variables : ${node.name} ${job.project}
remote - using unquoted nested options variables : ${node.name} ${job.project}
remote - what is expected : localhost rundeck

Expected behavior
The results for the remote steps should have the expanded values instead of the literal variable names.