Bug 1435446

Summary: Trigger yum update after RHELRegistration in initial deployment
Product: Red Hat OpenStack Reporter: Andreas Karis <akaris>
Component: openstack-tripleo-heat-templatesAssignee: Alex Schultz <aschultz>
Status: CLOSED ERRATA QA Contact: Gurenko Alex <agurenko>
Severity: medium Docs Contact:
Priority: medium    
Version: 10.0 (Newton)CC: aschultz, mburns, ohochman, rhel-osp-director-maint, tvignaud
Target Milestone: gaKeywords: Triaged
Target Release: 12.0 (Pike)   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: openstack-tripleo-heat-templates-7.0.0-0.20170616123155.el7ost Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-12-13 21:20:39 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Andreas Karis 2017-03-23 20:20:03 UTC
Description of problem:
Packages are not updated after RHEL Registration to Satellite server in initial stack creation. This seems to be an order of operations problem (or a design choice???)

UpdateDeployment stack resource is deployed before RHELRegistrationDeployment stack, therefore no packages updates are made. I have changed Compute and Controller Role YAML files as highlighted below to have all overcloud updated with all packages when overcloud is deployed. 

Version-Release number of selected component (if applicable):
[stack@undercloud-4 rhel-registration]$ rpm -qa | grep templates  | grep tripleo
openstack-tripleo-heat-templates-5.2.0-3.el7ost.noarch

How reproducible:
Deploy stack and register to satellite

Additional info:
In order to work around this, we made the following change (which still needs to be tested in the environment, but it should work):

Follow the documentation: https://access.redhat.com/documentation/en-us/red_hat_openstack_platform/10/html-single/advanced_overcloud_customization/#sect-Registering_the_Overcloud

It suggests to copy the registration files from the Heat template collection:
~~~
$ cp -r /usr/share/openstack-tripleo-heat-templates/extraconfig/pre_deploy/rhel-registration ~/templates/.
~~~

And then include those copied files:
~~~
$ openstack overcloud deploy --templates [...] -e /home/stack/templates/rhel-registration/environment-rhel-registration.yaml -e /home/stack/templates/rhel-registration/rhel-registration-resource-registry.yaml
~~~

What you can then do is, push your modification into 
/home/stack/templates/rhel-registration/rhel-registration.yaml

~~~
[stack@undercloud-4 rhel-registration]$ diff -c /usr/share/openstack-tripleo-heat-templates/extraconfig/pre_deploy/rhel-registration/rhel-registration.yaml /home/stack/templates/rhel-registration/rhel-registration.yaml 
*** /usr/share/openstack-tripleo-heat-templates/extraconfig/pre_deploy/rhel-registration/rhel-registration.yaml	2017-01-02 19:14:26.000000000 -0500
--- /home/stack/templates/rhel-registration/rhel-registration.yaml	2017-03-23 16:09:35.659288981 -0400
***************
*** 118,123 ****
--- 118,154 ----
        input_values:
          REG_METHOD: {get_param: rhel_reg_method}
  
+    YumUpdateConfigurationAfterRHELRegistration:
+      type: OS::Heat::SoftwareConfig
+      properties:
+        group: script
+        config: |
+          #!/bin/bash
+          set -x
+          list_updates=$(yum list -q updates)
+          if [[ "$list_updates" == "" ]]; 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"
+  
+    UpdateDeploymentAfterRHELRegistration:
+      type: OS::Heat::SoftwareDeployment
+      depends_on: RHELRegistrationDeployment
+      properties:
+        name: UpdateDeploymentAfterRHELRegistration
+        config: {get_resource: YumUpdateConfigurationAfterRHELRegistration}
+        server:  {get_param: server}
+        actions: ['CREATE'] # Only do this on CREATE
+        input_values:
+          update_identifier:
+            get_param: DeployIdentifier
+ 
  outputs:
    deploy_stdout:
      description: Deployment reference, used to trigger puppet apply on changes
~~~

Can we add this **by default** to the RHELRegistration templates?

Comment 1 Andreas Karis 2017-03-23 20:35:06 UTC
[stack@undercloud-4 rhel-registration]$ diff -c /usr/share/openstack-tripleo-heat-templates/extraconfig/pre_deploy/rhel-registration/rhel-registration.yaml /home/stack/templates/rhel-registration/rhel-registration.yaml 
*** /usr/share/openstack-tripleo-heat-templates/extraconfig/pre_deploy/rhel-registration/rhel-registration.yaml	2017-01-02 19:14:26.000000000 -0500
--- /home/stack/templates/rhel-registration/rhel-registration.yaml	2017-03-23 16:34:13.541312274 -0400
***************
*** 118,123 ****
--- 118,151 ----
        input_values:
          REG_METHOD: {get_param: rhel_reg_method}
  
+    YumUpdateConfigurationAfterRHELRegistration:
+      type: OS::Heat::SoftwareConfig
+      properties:
+        group: script
+        config: |
+          #!/bin/bash
+          set -x
+          list_updates=$(yum list -q updates)
+          if [[ "$list_updates" == "" ]]; 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"
+  
+    UpdateDeploymentAfterRHELRegistration:
+      type: OS::Heat::SoftwareDeployment
+      depends_on: RHELRegistrationDeployment
+      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

Comment 2 Andreas Karis 2017-03-24 16:23:29 UTC
Coming to think of it, this may actually be a design decision (not to run any packet updates). If this is the case, feel free to close out this bug report.

Comment 3 Alex Schultz 2017-03-24 16:42:43 UTC
No we have a similar bug upstream LP#1640894 which describes something similar situation so this sounds like a reasonable feature request for future releases. I'm not sure on a backport but I'll at least propose it upstream.

Comment 4 Andreas Karis 2017-03-24 16:59:08 UTC
Looking at the upstream bug, does this mean that if we simply set a dummy value for: UpdateIdentifer
... that this will trigger an initial update?

Comment 5 Alex Schultz 2017-03-24 18:23:06 UTC
So tracing through, it seems that if you set UpdateIdentifier it will perform a yum -y update as part of the deployment and switch to use the latest version of the packages available.  So would that work for you in this case or do we need to specifically need to run a yum update immediately after registering and before doing anything else?

Comment 10 Gurenko Alex 2017-12-13 09:13:25 UTC
Verified with build 2017-12-06.2

Comment 13 errata-xmlrpc 2017-12-13 21:20:39 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2017:3462