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

inspec vendor meta profiles fails when dependency profile is in Automate asset store #1632

Closed
jeremymv2 opened this issue Apr 5, 2017 · 2 comments · Fixed by #1647
Closed
Assignees

Comments

@jeremymv2
Copy link
Contributor

Description

Inspec meta profiles do not support profile dependencies residing in Automate when uploading a meta-profile.

InSpec and Platform Version

inspec 1.19.1

Replication Case

Upload a dependency profile to Automate, then create a meta-profile with the prior profile declared as a dependency via compliance: ../.. like so:

# profiles in Automate:
~/Devel/compliance-profiles.sav (test_upload *%)$ inspec compliance profiles

== Available profiles:

 * admin/meta-profile
 * admin/ssh

~/Devel/compliance-profiles.sav (test_upload *%)$ cat meta-profile/inspec.yml
name: meta-profile
title: Meta Compliance Profile
maintainer: InSpec Authors
copyright: InSpec Authors
copyright_email: support@chef.io
license: Apache 2
summary: InSpec Profile that is only consuming dependencies
version: 0.2.0
depends:
  - name: ssh
    compliance: admin/ssh
~/Devel/compliance-profiles.sav (test_upload *%)$ inspec compliance upload meta-profile --overwrite
WARN: Unresolved specs during Gem::Specification.reset:
      diff-lcs (< 2.0, >= 1.2.0)
      addressable (~> 2.4)
      net-ssh (< 5.0, >= 2.6.5, >= 2.9)
      ffi (>= 1.0.1)
      builder (>= 2.1.2)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
/Users/jmiller/.chefdk/gem/ruby/2.3.0/gems/inspec-1.19.1/lib/bundles/inspec-compliance/target.rb:84:in `compliance_profile_name': undefined method `[]' for nil:NilClass (NoMethodError)
	from /Users/jmiller/.chefdk/gem/ruby/2.3.0/gems/inspec-1.19.1/lib/bundles/inspec-compliance/target.rb:70:in `resolved_source'
	from /Users/jmiller/.chefdk/gem/ruby/2.3.0/gems/inspec-1.19.1/lib/inspec/cached_fetcher.rb:23:in `resolved_source'
	from /Users/jmiller/.chefdk/gem/ruby/2.3.0/gems/inspec-1.19.1/lib/inspec/dependencies/requirement.rb:63:in `resolved_source'
	from /Users/jmiller/.chefdk/gem/ruby/2.3.0/gems/inspec-1.19.1/lib/inspec/dependencies/resolver.rb:67:in `block in resolve'
	from /Users/jmiller/.chefdk/gem/ruby/2.3.0/gems/inspec-1.19.1/lib/inspec/dependencies/resolver.rb:59:in `each'
	from /Users/jmiller/.chefdk/gem/ruby/2.3.0/gems/inspec-1.19.1/lib/inspec/dependencies/resolver.rb:59:in `resolve'
	from /Users/jmiller/.chefdk/gem/ruby/2.3.0/gems/inspec-1.19.1/lib/inspec/dependencies/resolver.rb:31:in `resolve'
	from /Users/jmiller/.chefdk/gem/ruby/2.3.0/gems/inspec-1.19.1/lib/inspec/dependencies/dependency_set.rb:89:in `vendor'
	from /Users/jmiller/.chefdk/gem/ruby/2.3.0/gems/inspec-1.19.1/lib/inspec/profile.rb:385:in `generate_lockfile'
	from /Users/jmiller/.chefdk/gem/ruby/2.3.0/gems/inspec-1.19.1/lib/inspec/profile_vendor.rb:58:in `vendor_dependencies'
	from /Users/jmiller/.chefdk/gem/ruby/2.3.0/gems/inspec-1.19.1/lib/inspec/profile_vendor.rb:15:in `vendor!'
	from /Users/jmiller/.chefdk/gem/ruby/2.3.0/gems/inspec-1.19.1/lib/inspec/base_cli.rb:159:in `vendor_deps'
	from /Users/jmiller/.chefdk/gem/ruby/2.3.0/gems/inspec-1.19.1/lib/bundles/inspec-compliance/cli.rb:160:in `upload'
	from /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
	from /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
	from /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
	from /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:115:in `invoke'
	from /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor.rb:235:in `block in subcommand'
	from /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
	from /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
	from /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
	from /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
	from /Users/jmiller/.chefdk/gem/ruby/2.3.0/gems/inspec-1.19.1/bin/inspec:12:in `<top (required)>'
	from /opt/chefdk/embedded/bin/inspec:22:in `load'
	from /opt/chefdk/embedded/bin/inspec:22:in `<main>'
~/Devel/compliance-profiles.sav (test_upload *%)$

Possible Solutions

The issue comes from this location:
https://github.com/chef/inspec/blob/master/lib/bundles/inspec-compliance/target.rb#L83-L84

The scheme being matched is assuming standalone Compliance Server path ie. (/owners/../) Automate profile asset store does not have the same URI path therefore the []' for nil:NilClass error.

Stacktrace

Please include the stacktrace output or link to a gist of it, if there is one.

@chris-rock
Copy link
Contributor

@jeremymv2 have you vendored the profiles? see http://lollyrock.com/articles/chef-compliance-meta-profiles

@jeremymv2
Copy link
Contributor Author

jeremymv2 commented Apr 5, 2017

@chris-rock Yes, I believe I'm vendoring the profile correctly. It actually appears to be failing on that step. There's not much to the profile at all, just a reference in the inspec.yml to a profile (admin/ssh) that I've already uploaded to Automate. My ~/.inspec/compliance/config.json points to the Automate server - which I've logged into with token.

Here is the profile:

~/Devel/compliance-profiles.sav (test_upload *%)$ tree meta-profile
meta-profile
├── README.md
├── controls
│   └── example.rb
├── inspec.yml
└── vendor
    └── 4c645efb291cf08200cf7841227ba4e76c45105b5fcb47f546ae448e77395e4f.tar.gz

2 directories, 4 files
~/Devel/compliance-profiles.sav (test_upload *%)$ cat meta-profile/inspec.yml
name: meta-profile
title: Meta Compliance Profile
maintainer: InSpec Authors
copyright: InSpec Authors
copyright_email: support@chef.io
license: Apache 2
summary: InSpec Profile that is only consuming dependencies
version: 0.2.0
depends:
  - name: ssh
    compliance: admin/ssh
~/Devel/compliance-profiles.sav (test_upload *%)$ cat meta-profile/controls/example.rb
# encoding: utf-8
# copyright: 2015, The Authors
# license: All rights reserved
~/Devel/compliance-profiles.sav (test_upload *%)$

Vendoring:

~/Devel/compliance-profiles.sav (test_upload *%)$ inspec vendor meta-profile --overwrite
WARN: Unresolved specs during Gem::Specification.reset:
      diff-lcs (< 2.0, >= 1.2.0)
      addressable (~> 2.4)
      net-ssh (< 5.0, >= 2.6.5, >= 2.9)
      ffi (>= 1.0.1)
      builder (>= 2.1.2)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
/Users/jmiller/.chefdk/gem/ruby/2.3.0/gems/inspec-1.19.1/lib/bundles/inspec-compliance/target.rb:84:in `compliance_profile_name': undefined method `[]' for nil:NilClass (NoMethodError)
	from /Users/jmiller/.chefdk/gem/ruby/2.3.0/gems/inspec-1.19.1/lib/bundles/inspec-compliance/target.rb:70:in `resolved_source'
	from /Users/jmiller/.chefdk/gem/ruby/2.3.0/gems/inspec-1.19.1/lib/inspec/cached_fetcher.rb:23:in `resolved_source'
	from /Users/jmiller/.chefdk/gem/ruby/2.3.0/gems/inspec-1.19.1/lib/inspec/dependencies/requirement.rb:63:in `resolved_source'
	from /Users/jmiller/.chefdk/gem/ruby/2.3.0/gems/inspec-1.19.1/lib/inspec/dependencies/resolver.rb:67:in `block in resolve'
	from /Users/jmiller/.chefdk/gem/ruby/2.3.0/gems/inspec-1.19.1/lib/inspec/dependencies/resolver.rb:59:in `each'
	from /Users/jmiller/.chefdk/gem/ruby/2.3.0/gems/inspec-1.19.1/lib/inspec/dependencies/resolver.rb:59:in `resolve'
	from /Users/jmiller/.chefdk/gem/ruby/2.3.0/gems/inspec-1.19.1/lib/inspec/dependencies/resolver.rb:31:in `resolve'
	from /Users/jmiller/.chefdk/gem/ruby/2.3.0/gems/inspec-1.19.1/lib/inspec/dependencies/dependency_set.rb:89:in `vendor'
	from /Users/jmiller/.chefdk/gem/ruby/2.3.0/gems/inspec-1.19.1/lib/inspec/profile.rb:385:in `generate_lockfile'
	from /Users/jmiller/.chefdk/gem/ruby/2.3.0/gems/inspec-1.19.1/lib/inspec/profile_vendor.rb:58:in `vendor_dependencies'
	from /Users/jmiller/.chefdk/gem/ruby/2.3.0/gems/inspec-1.19.1/lib/inspec/profile_vendor.rb:15:in `vendor!'
	from /Users/jmiller/.chefdk/gem/ruby/2.3.0/gems/inspec-1.19.1/lib/inspec/base_cli.rb:159:in `vendor_deps'
	from /Users/jmiller/.chefdk/gem/ruby/2.3.0/gems/inspec-1.19.1/lib/inspec/cli.rb:114:in `vendor'
	from /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
	from /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
	from /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
	from /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
	from /Users/jmiller/.chefdk/gem/ruby/2.3.0/gems/inspec-1.19.1/bin/inspec:12:in `<top (required)>'
	from /opt/chefdk/embedded/bin/inspec:22:in `load'
	from /opt/chefdk/embedded/bin/inspec:22:in `<main>'
~/Devel/compliance-profiles.sav (test_upload *%)$

During the vendoring it appears to be failing on https://github.com/chef/inspec/blob/master/lib/bundles/inspec-compliance/target.rb#L83-L84 because of path scheme in config.json is expecting the path for Compliance profiles, ie owners/owner_name/compliance/profile_name. The server key in ~/.inspec/compliance/config.json for Automate is different: "server":"https://automate-server.test/compliance/profiles".

@jeremymv2 jeremymv2 changed the title inspec meta profiles do not support dependency profiles in Automate asset store inspec vendor meta profiles fails when dependency profile is in Automate asset store Apr 11, 2017
@chris-rock chris-rock self-assigned this Apr 12, 2017
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.

4 participants