Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ChefSpec and Ohai/Fauxhai: cpu #41

Closed
rmoriz opened this issue Aug 21, 2014 · 1 comment · Fixed by #55
Closed

ChefSpec and Ohai/Fauxhai: cpu #41

rmoriz opened this issue Aug 21, 2014 · 1 comment · Fixed by #55

Comments

@rmoriz
Copy link

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 ChefSpec and Ohai/Fauhai: cpu ChefSpec and Ohai/Fauxhai: cpu Aug 21, 2014
@chris-rock
Copy link
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.

chris-rock added a commit that referenced this issue Sep 16, 2014
chris-rock added a commit that referenced this issue Sep 16, 2014
rollbrettler pushed a commit to rollbrettler/chef-os-hardening that referenced this issue Sep 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants