Inspec Test of Ohai Plugin - Odd Behavior


Hello all. I’m experimenting with a simple custom ohai plugin and hitting an odd problem during local kitchen testing with Vagrant/VirtualBox. I’m hoping someone can tell me how to resolve it (or what to look at more closely). Here goes: Starting from scratch (i.e., no virtualbox vm running), my inspec test passes at the end of ‘kitchen verify centos’. If I test from scratch with windows (i.e., ‘kitchen verify windows’), the inspec test fails, but if I immediately re-run ‘kitchen verify windows’, the inspec test passes. Does this behavior ring a bell with anyone? Below are additional details.

Here’s my plugin code (virtualbox_tags.rb):

Ohai.plugin(:VirtualBoxTags) do
  provides 'tags'
  collect_data :default do
    tags[:plugin] = 'Corporate Tags Ohai Plugin'
    tags[:provider] = 'VirtualBox'
    tags[:virtualbox_tag1] = 'virtualbox_tag1 value'
    tags[:virtualbox_tag2] = 'virtualbox_tag2 value'
    tags[:virtualbox_tag3] = 'virtualbox_tag3 value'

Here’s my recipe to install the plugin (default.rb):

ohai_plugin 'virtualbox_tags'

Here’s my inspec test (default_test.rb):

case os[:family]
when 'windows'
  plugin_directory = 'C:/Users/vagrant/AppData/Local/Temp/kitchen/ohai/plugins'
when 'redhat' # Includes RHEL and CentOS
  plugin_directory = '/tmp/kitchen/ohai/plugins'
describe command("ohai -d #{plugin_directory} tags") do
  its(:stdout) { should match(/corporate tags ohai plugin/i) }

The error I get when testing windows from scratch is ‘expected “” to match /corporate tags ohai plugin/i’.

If I RDP into the windows test box immediately after the error, I can see that the text the test is trying to match is present in the plugin file (in C:/Users/vagrant/AppData/Local/Temp/kitchen/ohai/plugins).

Any help is appreciated. Thanks!