Allow for update after RHEL registration
authorAlex Schultz <aschultz@redhat.com>
Fri, 24 Mar 2017 16:33:48 +0000 (10:33 -0600)
committerAlex Schultz <aschultz@redhat.com>
Fri, 7 Apr 2017 15:05:09 +0000 (09:05 -0600)
Adds the ability to perform a yum update after performing the RHEL
registration.

Change-Id: Id84d156cd28413309981d5943242292a3a6fa807
Partial-Bug: #1640894

extraconfig/pre_deploy/rhel-registration/rhel-registration.yaml
releasenotes/notes/update-on-rhel-registration-afbef3ead983b08f.yaml [new file with mode: 0644]

index e8316c5..30a8355 100644 (file)
@@ -53,6 +53,12 @@ parameters:
     type: string
   rhel_reg_http_proxy_password:
     type: string
+  UpdateOnRHELRegistration:
+    type: boolean
+    default: false
+    description: |
+      When enabled, the system will perform a yum update after performing the
+      RHEL Registration process.
 
 resources:
 
@@ -134,6 +140,37 @@ resources:
       input_values:
         REG_METHOD: {get_param: rhel_reg_method}
 
+  YumUpdateConfigurationAfterRHELRegistration:
+    type: OS::Heat::SoftwareConfig
+    properties:
+      group: script
+      config: |
+        #!/bin/bash
+        set -x
+        num_updates=$(yum list -q updates | wc -l)
+        if [ "$num_updates" -eq "0" ]; then
+           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
+    depends_on: RHELRegistrationDeployment
+    conditions:
+      update_requested: {get_param: UpdateOnRHELRegistration}
+    properties:
+      name: UpdateDeploymentAfterRHELRegistration
+      config: {get_resource: YumUpdateConfigurationAfterRHELRegistration}
+      server:  {get_param: server}
+      actions: ['CREATE'] # Only do this on CREATE
+
 outputs:
   deploy_stdout:
     description: Deployment reference, used to trigger puppet apply on changes
diff --git a/releasenotes/notes/update-on-rhel-registration-afbef3ead983b08f.yaml b/releasenotes/notes/update-on-rhel-registration-afbef3ead983b08f.yaml
new file mode 100644 (file)
index 0000000..ad1f39c
--- /dev/null
@@ -0,0 +1,6 @@
+---
+features:
+  - |
+    Adds a new boolean parameter for RHEL Registration called
+    'UpdateOnRHELRegistration' that when enabled will trigger a yum update
+    on the node after the registration process completes.