chef-cookbooks / aix

Resources for AIX hosts
https://supermarket.chef.io/cookbooks/aix
Apache License 2.0
23 stars 42 forks source link

"aix_chdev" chokes on string attributes #94

Closed trickyearlobe closed 6 years ago

trickyearlobe commented 6 years ago

Cookbook version

2.2.0

Chef-client version

13.8.5

Platform Details

AIX 7.2

Scenario:

Customer complained that he was trying to set the state of en0 to up using the aix_chdev resource, but the resource was complaining there was no attribute state.

The customer verified there is an attribute called state using lsattr -El en0

After a little investigation, we see that the resource requires the attribute to be a lower case Symbol but thats not obvious without some debug which is confusing the customer.

Steps to Reproduce:

Create a wrapper cookbook containing a resource definition as follows:-

aix_chdev "en1" do 
  attributes("state" => "up")
  action :update 
end

Expected Result:

State of en0 gets set to up

Actual Result:

We get a stack trace

Recipe: aix_wrapper::default
  * aix_chdev[en0] action update

    ================================================================================
    Error executing action `update` on resource 'aix_chdev[en0]'
    ================================================================================

    RuntimeError
    ------------
    chdev device en0 has not attribute state

    Cookbook Trace:
    ---------------
    /var/chef/cache/cookbooks/aix/resources/chdev.rb:71:in `block (2 levels) in class_from_file'
    /var/chef/cache/cookbooks/aix/resources/chdev.rb:51:in `each'
    /var/chef/cache/cookbooks/aix/resources/chdev.rb:51:in `block in class_from_file'

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

     22: aix_chdev 'en0' do
     23:   attributes('state' => 'up')
     24:   action :update
     25: end

    Compiled Resource:
    ------------------
    # Declared in /var/chef/cache/cookbooks/aix_wrapper/recipes/default.rb:22:in `from_file'

    aix_chdev("en0") do
      action [:update]
      default_guard_interpreter :default
      declared_type :aix_chdev
      cookbook_name "aix_wrapper"
      recipe_name "default"
      attributes {"state"=>"up"}
    end

    System Info:
    ------------
    chef_version=13.8.5
    platform=aix
    platform_version=7.2
    ruby=ruby 2.4.3p205 (2017-12-14 revision 61247) [powerpc-aix6.1.0.0]
    program_name=chef-client worker: ppid=16777474;start=16:13:26;
    executable=/opt/chef/bin/chef-client