how to get information about chef provisioner (chef-zero or not) inside a chef recipe?

118 views Asked by At

In my recipe I want to find out the the mode in which chef is running and load from data bag based on that. If it is running chef-zero then I will load the data bag in a specific way and if not in a different way .

if Chef::Config[:zero] == 'true'
  //Load unencryted databag from local
else
 //Load encrypted databag
end

But currently it always enters the else block. I am running kitchen with

provisioner:
  name: chef_zero
2

There are 2 answers

0
Shamik On BEST ANSWER

Answering my own question - The solution i was looking for is using kitchen attributes.

https://stackoverflow.com/a/38429417/888070

3
coderanger On

If you use the data_bag_item() helper it will handle this for you internally. It is better to avoid explicit branching whenever possible.