TyMac
TyMac

Reputation: 803

Users cookbook failing in Test Kitchen but working in bootstrap

I have a simple recipe that added users to a Centos 7.3 machine:

users_manage 'sales' do
  group_id 5000
  action [:create]
  data_bag 'sales_users'
end

users_manage 'mechanics' do
  group_id 6000
  action [:create]
  data_bag 'shop_users'
end

The data bags work as when using the the standard knife boostrap the client converges the recipe and adds the users... however. Test Kitchen is failing with the following error:

       Error executing action `create` on resource 'users_manage[sales]'


       NoMethodError
       -------------
       undefined method `supports' for Chef::Resource::User::LinuxUser

Looking in the Test Kitchen's VM I can locate the data bags in the /tmp/kitchen/data_bags directory. This was working in Test Kitchen and I'm not sure what would have stopped it from working as I'm not sure what that error means...

Upvotes: 1

Views: 361

Answers (1)

coderanger
coderanger

Reputation: 54191

You are installing Chef 13 in Test Kitchen but 12 in production. Fix that by adding this to your .kitchen.yml (update the existing provisioner section if it already exists):

provisioner:
  name: whatever_you_have
  require_chef_omnibus: 12

I think the users cookbook was also recently updated for Chef 13 so if you do want to keep testing on that for upgrade purposes, check if something is preventing the upgrade.

Upvotes: 1

Related Questions