Rundeck setsup all the options passed to a job as environment variable like $RD_OPTION_*
but it is not setting up those variables when a job is executed in remote node with different ssh port. The script logs into remote node successfully but environment variables are not there. Please help me with a solution.
Sample Job definition:
<joblist>
<job>
<context>
<options preserveOrder='true'>
<option name='option1' required='true' />
</options>
</context>
<description>job description</description>
<dispatch>
<excludePrecedence>true</excludePrecedence>
<keepgoing>false</keepgoing>
<rankOrder>ascending</rankOrder>
<threadcount>1</threadcount>
</dispatch>
<executionEnabled>true</executionEnabled>
<id>id</id>
<loglevel>DEBUG</loglevel>
<name>job name</name>
<nodefilters>
<filter>name: remote_node</filter>
</nodefilters>
<nodesSelectedByDefault>true</nodesSelectedByDefault>
<notification>
<onfailure>
<email attachLog='true' recipients='abcdef@xyz.com' subject='job failure :(' />
</onfailure>
<onsuccess>
<email recipients='abcdef@xyz.com' subject='job succes' />
</onsuccess>
</notification>
<scheduleEnabled>true</scheduleEnabled>
<sequence keepgoing='false' strategy='step-first'>
<command>
<exec>python path/to/script.py $RD_OPTION_OPTION1 > /path/to/logfile_$RD_JOB_EXECID.log 2>&1</exec>
</command>
<command>
<exec>java -jar path/to/jarfile.jar ${option.option1} >> "/path/to/logfile_${job.execid}.log" 2>&1</exec>
</command>
</sequence>
<uuid>job-uuid</uuid>
</job>
</joblist>
<!--
Here
$RD_JOB_EXECID,${job.execid},${option.option1},$RD_OPTION_OPTION1 are not being setup as environment variables when remote node is selected for execution
but the same variables are set up as environment variables when executed locally.
Rundeck logins to the remote node as user successfully.
Log entries are seen in /path/to/logfile_.log file in remote node since $RD_JOB_EXECID has not been set up.
the options @option.option1@ are working fine since they have been replaced by rundeck before executing command.
Rundeck details:
user: rundeck
shell: /bin/nologin
rundeck logs into remote server as normal user who has all permissions to execute all these scripts/jars.
-->
Note:
Rundeck is not setting up environment variables when executed on remote instance with different ssh port. In this case port is 2808 and the same has been updated in resources.xml as 123.456.789.0:2808
. Rundeck logs into server and executes scripts successfully (without environment variables). Remote instance sshd_config has been configured to accept RD_* variables. The same Environment variables are set up and accessed when logged in using port 22
.