7. Local vs Built-in Resources
7.1. Local Resource
Local resources exist only in the profile they are developed in. As was shown in the previous example, a local resource would be placed in the libraries
directory
$ tree examples/profile
examples/profile
...
├── libraries
│ └── custom_resource.rb
From there you would develop your custom resource custom_resource.rb
and be able to utilize the resource within that profile.
7.2. Built-in InSpec Resource
Sometimes when working on resources you may find a gap in InSpec where a resource doesn't exist where it should. In a situation such as that you may want to develop a resource for upstream InSpec in Github. When developing a resource for InSpec you touch a few more files than just the custom_resource.rb
as mentioned before.
First you would have to fork a copy of the InSpec Github Repo to make the necessary changes to the repository.
The following directories are the ones you would want to change:
For the actual resource you can place it in lib/inspec/resources/
.
You have to add your new resource to the helper file in lib/inspec/resources.rb
Then you have to write out your integration tests for the resource in this directory test/integration/default/controls/
Next you are required to write the unit tests for your new resource here test/unit/resources/
Finally, you will have to write up the documentation that will be put up on InSpec's official doc page here docs/resources/