From 2e38cba405b9c4b9f40cffce969cda129df044ae Mon Sep 17 00:00:00 2001 From: Jose Luis Franco Arza Date: Thu, 24 Jan 2019 15:31:30 +0100 Subject: [PATCH] [Queens only] Include new parameter RHELRegistrationUpgrade to rhel-registration. Setting the rhel_reg_force parameter to true during upgrade prepare doesn't work correctly when the customer passes the rhel-registration/ environment-rhel-registration.yaml, as this template sets an empty value for that parameter by default (an which is usually not modified by the user). As environments/lifecycle/upgrade-prepare.yaml is prepended, any template setting a different value for rhel_reg_force param will have precedence on what we set in the upgade-prepare.yaml env file. The solution is creating a new parameter RHELRegistrationUpgrade, which defaults to false and which we ensure it's set to true during upgrade prepare by setting it in environments/lifecycle/upgrade-prepare.yaml. When RHELRegistrationUpgrade is set to True we enforce that REG_FORCE sets to True, otherwise it will simply take the value passed in the heat parameter rhel_reg_force. Closes-Bug: #1813184 Change-Id: Idc1bdad0a19150569dacb88abd539d86741bc643 --- environments/lifecycle/upgrade-converge.yaml | 2 +- environments/lifecycle/upgrade-prepare.yaml | 2 +- .../rhel-registration/rhel-registration.yaml | 10 +++++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/environments/lifecycle/upgrade-converge.yaml b/environments/lifecycle/upgrade-converge.yaml index 187893fc69..796bc96902 100644 --- a/environments/lifecycle/upgrade-converge.yaml +++ b/environments/lifecycle/upgrade-converge.yaml @@ -14,4 +14,4 @@ parameter_defaults: # Unset RHEL registration parameters to avoid # re-registering on future stack updates. RHELRegistrationActions: 'CREATE' - rhel_reg_force: "" + RHELRegistrationUpgrade: true diff --git a/environments/lifecycle/upgrade-prepare.yaml b/environments/lifecycle/upgrade-prepare.yaml index 8238d3e33d..3820babaab 100644 --- a/environments/lifecycle/upgrade-prepare.yaml +++ b/environments/lifecycle/upgrade-prepare.yaml @@ -24,4 +24,4 @@ parameter_defaults: # Add RHEL Registration force to re-register with the new key and repos # also modify the actions to run the resource on stack UPDATE RHELRegistrationActions: ['CREATE', 'UPDATE'] - rhel_reg_force: "True" + RHELRegistrationUpgrade: true diff --git a/extraconfig/pre_deploy/rhel-registration/rhel-registration.yaml b/extraconfig/pre_deploy/rhel-registration/rhel-registration.yaml index 1e32618d8a..bf725200be 100644 --- a/extraconfig/pre_deploy/rhel-registration/rhel-registration.yaml +++ b/extraconfig/pre_deploy/rhel-registration/rhel-registration.yaml @@ -70,6 +70,10 @@ parameters: default: - CREATE description: Actions when the system profile will be registered, by default we only do this on CREATE of a new server, not for existing nodes. + RHELRegistrationUpgrade: + type: boolean + default: false + description: Forces the registration when performing an upgrade. conditions: unregister_on_delete: @@ -80,6 +84,10 @@ conditions: equals: - {get_param: UpdateOnRHELRegistration} - true + upgrading: + equals: + - { get_param: RHELRegistrationUpgrade } + - true resources: @@ -124,7 +132,7 @@ resources: REG_AUTO_ATTACH: {get_param: rhel_reg_auto_attach} REG_BASE_URL: {get_param: rhel_reg_base_url} REG_ENVIRONMENT: {get_param: rhel_reg_environment} - REG_FORCE: {get_param: rhel_reg_force} + REG_FORCE: {if: [upgrading, "True", {get_param: rhel_reg_force}]} REG_MACHINE_NAME: {get_param: rhel_reg_machine_name} REG_ORG: {get_param: rhel_reg_org} REG_PASSWORD: {get_param: rhel_reg_password}