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?