From b336b45102a0201bb0e8f5c583697fa1083e232e Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Tue, 21 Nov 2017 15:00:23 -0800 Subject: [PATCH] RHEL/Update: replace wc by yum to check updates Similar to I8bd89f2b24bafc6c991382b9eb484cfa9a2f8968, use yum to check if updates are available during RHEL registration and run upgrades only when there are some. Change-Id: I42cd699d21cbec7d754edf1b8d83e75de0f2c7d9 --- .../rhel-registration/rhel-registration.yaml | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) 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