Problem:
Remote Execution feature (REX) is functioning, but it reports a ‘success’ exit status for remote commands even when they fail.
For example:
[root@foreman ~]# hammer job-invocation create --job-template "Run Command - Script Default" --inputs command="blabla" --search-query "name ~ myhost.mydomain.com"
Job invocation 52 created
[.................................................................................................................................................................] [100%]
1 task(s), 1 success, 0 fail
[root@foreman ~]# hammer job-invocation output --host myhost.mydomain.com --id 52
/var/tmp/foreman-ssh-cmd-d602e532-4db6-423c-9a16-34f183ffb4dd/script: line 1: blabla: command not found
Exit status: 0
The command blabla
does not exist, so why is the job execution reported as successful?
The same behavior occurs when the command is run in the Web UI.
Expected outcome:
The exit status of a remote command should report the correct value:
- Success (0): when no errors occured while executing the remote command
- Failure (1): errors occured while executing the remote command
Foreman and Proxy versions:
[root@foreman ~]# hammer status
Version: 3.12.0
API Version: v2
Database:
Status: ok
Server Response: Duration: 0ms
Plugins:
1) Name: foreman-tasks
Version: 9.2.3
2) Name: foreman_remote_execution
Version: 13.2.5
3) Name: foreman_templates
Version: 9.5.1
4) Name: katello
Version: 4.14.0
Smart Proxies:
1) Name: foreman.<redacted>
Version: 3.12.0
Status: ok
Features:
1) Name: dynflow
Version: 0.9.3
2) Name: pulpcore
Version: 3.3.0
3) Name: script
Version: 0.11.3
4) Name: templates
Version: 3.12.0
5) Name: tftp
Version: 3.12.0
6) Name: logs
Version: 3.12.0
7) Name: registration
Version: 3.12.0
Compute Resources:
candlepin:
Status: ok
Server Response: Duration: 14ms
candlepin_auth:
Status: ok
Server Response: Duration: 12ms
candlepin_events:
Status: ok
message: 1 Processed, 0 Failed
Server Response: Duration: 0ms
katello_events:
Status: ok
message: 1 Processed, 0 Failed
Server Response: Duration: 0ms
pulp3:
Status: ok
Server Response: Duration: 47ms
pulp3_content:
Status: ok
Server Response: Duration: 47ms
foreman_tasks:
Status: ok
Server Response: Duration: 3ms
Distribution and version:
CentOS Stream 9