Bug 1459468

Summary: overcloud registration script check only if rhel_reg_auto_attach is present or not so rhel_reg_auto_attach: "False" count as true
Product: Red Hat OpenStack Reporter: Eduard Barrera <ebarrera>
Component: openstack-tripleo-heat-templatesAssignee: Emilien Macchi <emacchi>
Status: CLOSED CURRENTRELEASE QA Contact: Gurenko Alex <agurenko>
Severity: medium Docs Contact:
Priority: medium    
Version: 10.0 (Newton)CC: aschultz, dmacpher, ebarrera, emacchi, jschluet, jslagle, mburns, ohochman, rhel-osp-director-maint
Target Milestone: Upstream M2Keywords: Triaged
Target Release: 13.0 (Queens)   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-02-19 16:40:12 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 Eduard Barrera 2017-06-07 08:57:14 UTC
Description of problem:

overcloud registration script check only if rhel_reg_auto_attach is present or not so rhel_reg_auto_attach: "False" count as true

The registration script seems to check only if the variable is defined or not:

...
if [ -n "${REG_ACTIVATION_KEY:-}" ]; then
    opts="$opts --activationkey=$REG_ACTIVATION_KEY"
    sat5_opts="$sat5_opts --activationkey=$REG_ACTIVATION_KEY"

    if [ -z "${REG_ORG:-}" ]; then
        echo "WARNING: REG_ACTIVATION_KEY set without REG_ORG."
    fi
else
    echo "WARNING: Support for registering with a username and password is deprecated."
    echo "Please use activation keys instead.  See the README for more information."
    if [ -n "${REG_PASSWORD:-}" ]; then
        opts="$opts --password $REG_PASSWORD"
    fi

    if [ -n "${REG_USER:-}" ]; then
        opts="$opts --username $REG_USER"
    fi
fi
...

So if you have   rhel_reg_auto_attach: "False" you will get the error anyway:

    Error: Activation keys cannot be used with --auto-attach.
overcloud.ContrailController.0.SshHostPubKey:
  resource_type: OS::TripleO::Ssh::HostPubKey
  physical_resource_id: 7e65bfce-cc61-47c3-ab1a-39a5102a0698
  status: CREATE_FAILED



Version-Release number of selected component (if applicable):


How reproducible:
always


Steps to Reproduce:
1. Deploy overcloud with similar  registration template



parameter_defaults:
  rhel_reg_activation_key: "RH73"
  rhel_reg_auto_attach: "False"
  rhel_reg_base_url: "http://192.1.1.2"
  rhel_reg_environment: ""
  rhel_reg_force: ""
  rhel_reg_machine_name: ""
  rhel_reg_org: "XXXXX-8b4f-XXXX-XXXXX-XXXXXXXXXXXXXXXXXXX"
  rhel_reg_password: "ofuscated"
  rhel_reg_pool_id: ""
  rhel_reg_release: ""
  rhel_reg_repos: "rhel-7-server-rpms rhel-7-server-extras-rpms rhel-7-server-rh-common-rpms rhel-ha-for-rhel-7-server-rpms rhel-7-server-openstack-10-rpms rhel-7-server-openstack-10-devtools-rpms"
  rhel_reg_sat_url: "http://192.1.1.2"
  rhel_reg_server_url: ""
  rhel_reg_service_level: ""
  rhel_reg_user: "user"
  rhel_reg_type: ""
  rhel_reg_method: "satellite"
  rhel_reg_sat_repo: "rhel-7-server-satellite-tools-6.1-rpms"
2.
3.

Actual results:
   Error: Activation keys cannot be used with --auto-attach.
overcloud.ContrailController.0.SshHostPubKey:
  resource_type: OS::TripleO::Ssh::HostPubKey
  physical_resource_id: 7e65bfce-cc61-47c3-ab1a-39a5102a0698
  status: CREATE_FAILED



Expected results:

rhel_reg_auto_attach: "False" honored 

Additional info:

Comment 1 Alex Schultz 2017-06-19 20:36:30 UTC
In this particular case, "" would be used to disable it. The documentation around these parameters are lacking but the checks around these variables seem to to use "" as the disabled string.

Comment 2 James Slagle 2017-07-18 11:21:27 UTC
i think the fix here ought to be to document these parameters using the environment generator so it's clear how to use them.

Comment 6 Emilien Macchi 2017-11-02 21:43:55 UTC
I can't find where it's said to set rhel_reg_auto_attach to True or False. While I agree this is not obvious, you might want to just ignore this parameter if you don't want to auto_attach.
We can fix this bug in 2 ways:

- Document the parameter
- Sanitize the parameter and check content

FWIW, I prefer our users to ignore the parameter if they don't want auto-attach, and use whatever string (true, True, whatever) to enable it.

I'm happy to fix it in the code, in the way you like, just tell me what you prefer.

Comment 10 Emilien Macchi 2017-11-21 22:37:22 UTC
Alright, no reply from Eduard so we'll proceed with option 1, documentation.

Dan, could we please document that "rhel_reg_auto_attach" parameter should only be used when set to True. When we don't need it, don't set it to False, just do nothing, the default is "" so the feature will be disabled anyway.

Thanks

Comment 19 Emilien Macchi 2018-02-14 20:24:09 UTC
This bug affects all versions of OSP since we have RHEL scripts. To me it's a doc fix, we're moving to Ansible and won't have this code in the future.

Comment 20 Emilien Macchi 2018-02-14 20:27:45 UTC
Sorry for the confusion in https://bugzilla.redhat.com/show_bug.cgi?id=1459468#c14 but the comment was about documentation. Yes, we should backport the doc change into OSP10 and 11.

Comment 21 Emilien Macchi 2018-02-14 20:28:31 UTC
Hey Dan, can you please proceed to the backports for the older versions of OSP?
OSP10 and 11 are enough IMHO.

Thanks

Comment 22 Dan Macpherson 2018-02-19 04:43:41 UTC
Backported and published!

Comment 23 Emilien Macchi 2018-02-19 16:40:12 UTC
Thanks Dan!

Closing the bug as we improved the documentation.