Using Inspec with Policyfile in Test Kitchen


#1

Hi I have a .kitchen.yml file as the below and it is using Policyfile_zero as the provision.

Now I want to use Inspec to do the kitchen verify on the VM created using kitchen create (via Vagrant).

I run the kitchen verify but the verify rules are not running. However the kitchen converge is running successfully.

To make Inspec working under Policyfile provisioner in test kitchen, How to do that?

---
driver:
  name: vagrant

provisioner:
  name: policyfile_zero

platforms:
  - name: centos/7

suites:
  - name: local_test
    data_bags_path: "test/data_bags"
    provisioner:
      policyfile: local_test.rb
    verifier:
      inspec_tests:
        - test/smoke/default

Here are the test rules (test/smoke/default/default_test.rb):

describe user('gituser') do
  it { should exist }
  its('uid') { should eq 2001 }
  its('gid') { should eq 2001 }
  its('group') { should eq 'gituser' }
  its('home') { should eq '/home/gituser' }
  its('shell') { should eq '/bin/bash' }
end

#2

We deprecated the policyfile_zero provisioner a long while back as native support was introduced way back in test-kitchen 1.8.0. Use the chef_zero provisioner and carry on as per normal.

If you have any issues or questions feel free to join us in the #test-kitchen channel on the Community Slack.