Image for post
Image for post

InSpec is a framework to create infrastructure tests for integration or compliance testing and is marketed as compliance as code. InSpec uses a similar syntax to ServerSpec. Currently, it is not feature parity with ServerSpec.

Tests are orchestrated using the inspec command. There is no further automation to integrate or further orchestrate tests directly on vagrant or docker using ruby workflow with rake or spec. For more advanced orchestration needs, you can use TestKitchen.

With ruby installed, you can install everything needed for InSpec with:

gem install inspec
inspec init profile $PROFILENAME

This will create the following structure, where $PROFILENAME matches the name of your choosing:

.
└─── $PROFILENAME
├── controls
│ └── example.rb
├── inspec.yml
├── libraries
└── README.md

In the control directory, you can add your test like the following below:

InSpec can use SSH to log into your systems and run tests. With vagrant you can run the tests by specifying the port, path to ssh private key, and the user name and host. You can get these values from values by typing vagrant ssh-config, and then replace the variables below with the required values.

inspec exec $PROFILENAME/ \
-t ssh://$TARGET_USER@$TARGET_HOST \
-p $TARGET_PORT \
-i $TARGET_IDENTITYFILE

Written by

Linux NinjaPants Automation Engineering Mutant — exploring DevOps, Kubernetes, CNI, IAC

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store