diff --git a/examples/inheritance/README.md b/examples/inheritance/README.md index b125cc38c..8baccaf2d 100644 --- a/examples/inheritance/README.md +++ b/examples/inheritance/README.md @@ -7,13 +7,59 @@ This example shows the use of InSpec [profile](../../docs/profiles.rst) inherita InSpec ships with built-in features to verify a profile structure. ```bash -$ inspec check examples/inheritance --profiles-path examples +$ inspec check examples/inheritance ``` ## Execute a profile -To run a profile on a local machine use `inspec exec /path/to/profile`. +To run a profile on a local machine use `inspec exec /path/to/profile`. All dependencies are automatically resolved. ```bash -$ inspec exec examples/inheritance --profiles-path examples +$ inspec exec examples/inheritance +``` + +## Set attributes for dependent profiles + +Without setting attributes, an `inspec exec` would return the following: + +``` +$ inspec git:(master) ✗ b inspec exec examples/inheritance + +Profile: InSpec example inheritance (inheritance) +Version: 1.0.0 +Target: local:// + + + ○ gordon-1.0: Verify the version number of Gordon (1 skipped) + ○ Can't find file "/tmp/gordon/config.yaml" + ✔ File content should match nil + ✔ ssh-1: Allow only SSH Protocol 2 + ✔ File /bin/sh should be owned by "root" + + File /tmp + ✔ should be directory + alice should + ✖ eq "bob" + + expected: "bob" + got: "alice" + + (compared using ==) + + should eq + ✖ "secret" + + expected: "secret" + got: nil + + (compared using ==) + + +Test Summary: 3 successful, 2 failures, 1 skipped +``` + +To pass in attributes, just call: + +``` +$ inspec exec examples/inheritance --attrs examples/profile-attribute.yml ``` diff --git a/examples/inheritance/controls/example.rb b/examples/inheritance/controls/example.rb index 9a1372f37..7aa9d5359 100644 --- a/examples/inheritance/controls/example.rb +++ b/examples/inheritance/controls/example.rb @@ -2,6 +2,7 @@ # copyright: 2016, Chef Software, Inc. # license: All rights reserved +# manipulate controls of `profile` include_controls 'profile' do skip_control 'tmp-1.0' @@ -9,3 +10,6 @@ include_controls 'profile' do impact 0.0 end end + +# load all controls of `profile-attribute` +include_controls 'profile-attribute' diff --git a/examples/inheritance/inspec.yml b/examples/inheritance/inspec.yml index 636e6fe0e..e195d494b 100644 --- a/examples/inheritance/inspec.yml +++ b/examples/inheritance/inspec.yml @@ -11,3 +11,5 @@ supports: depends: - name: profile path: ../profile + - name: profile-attribute + path: ../profile-attribute