2

I'm trying to use Vagrant and Chef to test encrypted data bags. I've created an encrypted data bag using

knife solo data bag create test test_service --data-bag-path ../../data_bags/ --secret-file ~/.chef/encrypted_data_bag_secret

and verified the items were created.

Added data_bag and encrypt key path to my Vagrant file

config.vm.provision :chef_solo do |chef| chef.log_level = :debug chef.data_bags_path = "../../data_bags" chef.encrypted_data_bag_secret_key_path = '~/.chef/encrypted_data_bag_secret'

The recipe contains

secret_key = Chef::EncryptedDataBagItem.load_secret("C:\\tmp\\vagrant-chef-3\\encrypted_data_bag_secret_key") usr_creds = chef::EncryptedDataBagItem.load("test","test_service", secret_key)

When Vagrant runs it loads the encrypted key

==> default: Running provisioner: chef_solo... Uploading chef encrypted data bag secret key...

but throws an error

ArgumentError

You must supply a name when declaring a chef resource

On the Vagrant box I can see that Vagrant creates 2 directories C:\tmp\vagrant-chef-3\chef-solo-1\cookbooks C:\tmp\vagrant-chef-3\chef-solo-2\data_bags

Within the solo.rb on the Vagrant box C:\tmp\vagrant-chef-3\solo.rb there is a setting for cookbooks and the encryption key but not for the location of the data bags

Through some trial and error it looks like Chef cannot find the location of the data bag. Am I missing something somewhere?

Garry Cyre
  • 41
  • 1
  • 2
  • Found the first error: chef::EncryptedDataBagItem.load("test","test_service", secret_key) 'chef' needs to be capitalized. Now I get the error: Data Bag Items must contain a Hash or Mash! – Garry Cyre Feb 02 '15 at 22:28
  • I've verified that the name of the .json file and id: are the same – Garry Cyre Feb 03 '15 at 00:28
  • I have now started getting this issue with both solo and zero. The data bag and item are in the file system and are mapped correctly but it cannot find the data bag item during a chef run. – SmudgerDan May 13 '15 at 08:37
  • Just to update my issue in the above comment was due to this error, where vagrant was calling chef-solo rather than zero https://github.com/mitchellh/vagrant/issues/5619 – SmudgerDan Jul 14 '15 at 11:28
  • ping, @SmudgerDan or Garry, did you get the chef solo vagrant working with encrypted data bags? I found a 2yr old repo to help ; 1.[] ; ; ; ; ; X.Knife-solo data bag by thbishop ; ; http://thbishop.com/knife-solo_data_bag/ – AnneTheAgile Aug 13 '15 at 17:04

0 Answers0