chef-boneyard / audit

Audit Cookbook for Chef Compliance
https://supermarket.chef.io/cookbooks/audit
Apache License 2.0
57 stars 59 forks source link

Fix node['audit'][inspec_version'] = 'latest' #409

Open deano2point0 opened 4 years ago

deano2point0 commented 4 years ago

Cookbook version

9.0.1

Chef-client version

14.14.29

Platform Details

Ubuntu 18.04

Scenario:

Trying to use the inspec_version attribute set to 'latest' so the audit cookbook will automatically install the latest version of inspec.

Steps to Reproduce:

use chef-client 14.14.29 use audit cookbook 9.0.1 set node attribute to 'latest' run chef-client

Expected Result:

Chef client should run.

Actual Result:

cannot compile:

ArgumentError
  -------------
  inspec_gem[inspec] (audit::inspec line 20) had an error: ArgumentError: Malformed version number string latest

  Cookbook Trace:
  ---------------
    /var/chef/cache/cookbooks/audit/resources/inspec_gem.rb:90:in `compatible_with_client?'
    /var/chef/cache/cookbooks/audit/resources/inspec_gem.rb:12:in `block in class_from_file'
    /var/chef/cache/cookbooks/audit/recipes/inspec.rb:24:in `from_file'
    /var/chef/cache/cookbooks/audit/recipes/default.rb:30:in `from_file'
    /var/chef/cache/cookbooks/auditprofiles/recipes/default.rb:7:in `from_file'

Relevant File Content:

/var/chef/cache/cookbooks/audit/resources/inspec_gem.rb:

   83:      if chef_gte_15?
   84:        # Chef-15 can only run with the version of inspec-core and train-core that's being bundled with
   85:        # It's pinned here: grep "inspec-" /opt/chef/bin/chef-client
   86:        Chef::Log.warn('inspec_gem: Chef Infra Client >= 15 detected, can only use the embedded InSpec gem!!!')
   87:        false
   88:      else
   89:        # min version required to run the audit handler
   90>>       Gem::Requirement.new(['>= 1.25.1']).satisfied_by?(Gem::Version.new(gem_version))
   91:      end
   92:    end
   93:
   94:    def chef_gte_15?
   95:      Gem::Requirement.new('>= 15').satisfied_by?(Gem::Version.new(Chef::VERSION))
   96:    end
   97:
   98:    def use_inspec_core?(gem_version)
   99:      return true if gem_version.nil? # latest version
welcomebot commented 4 years ago

Hey There It looks like this is the first issue you've filed against the chef-cookbooks project. I'm here to offer you a bit of extra help to make sure we can quickly get back to you. Make sure you've filled out all the fields in our issue template. Make sure you've provided us with the version of chef-client you're running, your operating system and the version of the cookbook. If you're not using the most up to date version of the cookbook then please make sure to update first. Lots of things change between versions even if you're issue isn't listed in the changelog. Finally please give us a detailed description of the issue you're having. The more we know about what you're trying to do, what actually happens, and how you can reproduce the problem, the better.

If you're looking for more immediate troubleshooting help make sure to check out #general on the Chef Community Slack. There's plenty of folks there willing to lend a helping hand. Thanks for the first issue. We hope we can get back to you soon with a solution.