ChefSpec and Ohai/Fauxhai: cpu #41

Closed
rmoriz opened this Issue Aug 21, 2014 · 1 comment

Comments

Projects
None yet
2 participants
@rmoriz

rmoriz commented Aug 21, 2014

Using ChefSpec (with Fauxhai, either Debian 7.6 or Ubuntu 12.04)

    Failure/Error: let(:chef_run) { ChefSpec::Runner.new.converge(described_recipe) }
     NoMethodError:
       undefined method `[]' for nil:NilClass

in: os-hardening/recipes/sysctl.rb

 25>> cpu_vendor = node['cpu']['0']['vendor_id']
 26:    .sub(/^.*GenuineIntel.*$/, 'intel')
 27:    .sub(/^.*AuthenticAMD.*$/, 'amd')

turns out, typical fauxhai node attributes don't contain the attribute required:

https://github.com/customink/fauxhai/blob/master/lib/fauxhai/platforms/debian/7.6.json#L585
https://github.com/customink/fauxhai/blob/master/lib/fauxhai/platforms/ubuntu/14.04.json#L494

This will byte everyone using ChefSpec and your cookbook.

You either want to soft-fail or try to convince the fauxhai guys to add the attribute.

Workaround until then:

  let(:chef_run) {
    ChefSpec::Runner.new do |node|
      node.automatic['cpu']['0']['vendor_id'] = 'GenuineIntel'
    end.converge(described_recipe)
  }

see https://github.com/sethvargo/chefspec#automatic-attributes

@rmoriz rmoriz changed the title from ChefSpec and Ohai/Fauhai: cpu to ChefSpec and Ohai/Fauxhai: cpu Aug 21, 2014

@chris-rock

This comment has been minimized.

Show comment
Hide comment
@chris-rock

chris-rock Aug 25, 2014

Member

Thanks @rmoriz for reporting this. We are using Foodcritic and Robocop already, but we will take a look into supporting chef spec as well.

Member

chris-rock commented Aug 25, 2014

Thanks @rmoriz for reporting this. We are using Foodcritic and Robocop already, but we will take a look into supporting chef spec as well.

chris-rock added a commit that referenced this issue Sep 16, 2014

chris-rock added a commit that referenced this issue Sep 16, 2014

@arlimus arlimus closed this in #55 Oct 7, 2014

rollbrettler pushed a commit to rollbrettler/chef-os-hardening that referenced this issue Sep 16, 2016

Merge pull request #41 from bkw/docFixes
fix filenames in comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment