chef-boneyard / redhat-subscription-manager-cookbook

Cookbook providing custom resources for interacting with Red Hat Subscription Manager
Apache License 2.0
4 stars 18 forks source link

rhsm_register resource fails on line 26 when activation_key not specified #40

Open p0six opened 6 years ago

p0six commented 6 years ago

Cookbook version

1.0.2

Chef-client version

12.21.26

Platform Details

Red Hat Enterprise Linux 7.3

Scenario:

Trying to execute the "rhsm_register" Chef resource by specifying "username" and "password" properties, as opposed to using the "activation_key" property. Line 26 in libraries/helpers.rb is looking for activation_key and returning an "undefined method empty? for nil:NilClass" error when it is not found. Activation keys are not required when specifying username/password and therefore the libraries/helpers.rb should not be looking for it when rhsm_regiser is used in conjunction with username/password.

Steps to Reproduce:

Define an rhsm_register resource using username/password without an activation_key.

Expected Result:

Successful registration to Satellite Server

Actual Result:

Cookbook throws NoMethodError: undefined method `empty?' for nil:NilClass

brett-petrusek commented 6 years ago

full error here:

Recipe: satellite-client::default
 * rhsm_register[XXX] action register

   ================================================================================
   Error executing action `register` on resource 'rhsm_register[XXX]'
   ================================================================================

   NoMethodError
   -------------
   undefined method `empty?' for nil:NilClass

   Cookbook Trace:
   ---------------
   /var/chef/cache/cookbooks/redhat_subscription_manager/libraries/helpers.rb:26:in `register_command'
   /var/chef/cache/cookbooks/redhat_subscription_manager/libraries/rhsm_register.rb:58:in `block (2 levels) in <class:RhsmRegister>'
   /var/chef/cache/cookbooks/redhat_subscription_manager/libraries/rhsm_register.rb:56:in `block in <class:RhsmRegister>'

   Resource Declaration:
   ---------------------
   # In /var/chef/cache/cookbooks/satellite-client/recipes/default.rb

    38:   rhsm_register node['fqdn'] do
    39:     satellite_host node['satellite-client']['capsule']['capsule_name']
    40:     username 'admin'
    41:     password 'XXX'
    42:     install_katello_agent node['satellite-client']['katello']
    43:     auto_attach true
    44:     action :register
    45:     #activation_key node['satellite-client']['key']
    46:     #organization node['satellite-client']['organization']
    47:     #ignore_failure true
    48:   end
    49: end

   Compiled Resource:
   ------------------
   # Declared in /var/chef/cache/cookbooks/satellite-client/recipes/default.rb:38:in `from_file'

   rhsm_register("XXX") do
     action [:register]
     retries 0
     retry_delay 2
     default_guard_interpreter :default
     declared_type :rhsm_register
     cookbook_name "satellite-client"
     recipe_name "default"
     satellite_host "XXX"
     username "admin"
     password "XXX"
     install_katello_agent false
     auto_attach true
     _name_unused "XXX"
   end

   System Info:
   ------------
   chef_version=12.21.26
   platform=redhat
   platform_version=6.9
   ruby=ruby 2.3.5p376 (2017-09-14 revision 59905) [x86_64-linux]
   program_name=chef-client worker: ppid=15482;start=20:35:42;
   executable=/opt/chef/bin/chef-client