diff --git a/extraconfig/pre_deploy/rhel-registration/rhel-registration.yaml b/extraconfig/pre_deploy/rhel-registration/rhel-registration.yaml index b9fd08b4db..d296073e2d 100644 --- a/extraconfig/pre_deploy/rhel-registration/rhel-registration.yaml +++ b/extraconfig/pre_deploy/rhel-registration/rhel-registration.yaml @@ -173,18 +173,26 @@ resources: config: | #!/bin/bash set -x - num_updates=$(yum list -q updates | wc -l) - if [ "$num_updates" -eq "0" ]; then + # yum check-update exits 100 if updates are available + set +e + check_update=$(yum check-update 2>&1) + check_update_exit=$? + set -e + if [[ "$check_update_exit" == "100" ]]; then + full_command="yum -q -y update" + echo "Running: $full_command" + result=$($full_command) + return_code=$? + echo "$result" + echo "yum return code: $return_code" + exit $return_code + elif [[ "$check_update_exit" == "1" ]]; then + echo "Failed to check for package updates" + echo "$check_update" + else echo "No packages require updating" exit 0 fi - full_command="yum -q -y update" - echo "Running: $full_command" - result=$($full_command) - return_code=$? - echo "$result" - echo "yum return code: $return_code" - exit $return_code UpdateDeploymentAfterRHELRegistration: type: OS::Heat::SoftwareDeployment