[chef] Re: Different data_bags in production and test-kitchen


Chronological Thread 
  • From: Lamont Granquist < >
  • To:
  • Subject: [chef] Re: Different data_bags in production and test-kitchen
  • Date: Thu, 20 Feb 2014 10:49:32 -0800

On 2/19/14 9:47 PM, 

 wrote:
Hi, I'm using test-kitchen with vagrant, and having trouble with the users
cookbook from opscode.

Suppose we have a bunch of 'users' data bag items and some of them have 'sudo'
in the array of groups. If we have a recipe that has users_manage "sudo",
kitchen converge removes the vagrant user from sudo group because we don't 
have
the vagrant user in our data_bags.

I could come up with a few work arounds:

A. Add vagrant user in our data_bags
B. Modify our cookbook so that users_manage "sudo" runs if it's not in Vagrant

you can 'detect' running on vagrant by looking for the presence of the vagrant user:

sudo "vagrant" do
  user "vagrant"
  only_if { Etc.getpwent("vagrant") }
end

this kind of arbitrary-probe-state-and-then-take-action pattern is one of the reasons why
pushing ruby code down to the server under management is really powerful.



Archive powered by MHonArc 2.6.16.

§