Remote execution in Satellite 6 fails with "Failed to execute script on remote machine, exit code: 126 "

Solution Verified - Updated

Environment

  • Red Hat Satellite 6

Issue

  • Remote execution in Red Hat Satellite 6 fails with following error.

    1: Error initializing command: RuntimeError - Failed to execute script on remote machine, exit code: 126.
    2: Exit status: EXCEPTION
    3: StandardError: Job execution failed
    

Resolution

It is either /var/tmp has noexec permission and/or fapolicyd is running/enforced on the Host:

  • Remove noexec from /var/tmp on the problematic host machine.

  • To remove noexec permanently edit /etc/fstab file and remove noexec from /var/tmp entry.

    # vim /etc/fstab
    
  • To remove noexec temporarily use the following command. Additional required parameters can also be added with following mount command.

    # mount -o remount,exec /var/tmp
    
  • If fapolicy is installed/running on the Host, add a rule in fapolicyd by
    creating a file, example, /etc/fapolicyd/rules.d/sample.rules
    and add below line:

    # Allow trusted user to run Foreman scripts
    allow perm=execute uid=1000 : dir=/var/tmp/
    
  • Update the rules and restart fapolicyd:

    # fapolicyd-cli --update
    # systemctl restart fapolicyd
    # systemctl status fapolicyd`
    
  • If there are any security guidelines that recommend not providing execute permissions on the OS partitions and /var/tmp on the hosts, the working directory of the remote execution plugin can be changed as an alternative. How to change the working directory of the remote execution plugin in Red Hat Satellite 6?

    For more KB articles/solutions related to Red Hat Satellite 6.x Remote Execution Issues, please refer to the Red Hat Satellite Consolidated Troubleshooting Article for Red Hat Satellite 6.x Remote Execution Issues

Root Cause

  • noexec is set on /var/tmp due to which remote execution script could not be executed on the host machine and failed with mentioned error.

  • and/or fapolicyd is enforce on the Host

Diagnostic Steps

  • Look for the following error under failed job task on Satellite WebUI >> Monitor >> Jobs >> Click on failed job

    1: Error initializing command: RuntimeError - Failed to execute script on remote machine, exit code: 126.
    2: Exit status: EXCEPTION
    3: StandardError: Job execution failed
    
  • Look for noexec in /etc/fstab and mount command.

    # mount | grep /var/tmp
    # grep "/var/tmp" /etc/fstab
    
SBR
Product(s)
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.