Open jakereps opened 3 years ago
I would also be willing to assist in any dev that may or may not be required to fix this, assuming it isn't user error 👍
+1
================================================================================
Recipe Compile Error in /tmp/kitchen/cache/cookbooks/tmg-splunk-client/recipes/default.rb
================================================================================
ChefVault::Exceptions::ItemNotFound
-----------------------------------
vault/splunk__default not found
Cookbook Trace: (most recent call first)
----------------------------------------
/tmp/kitchen/cache/cookbooks/chef-vault/libraries/helpers.rb:37:in `chef_vault_item'
/tmp/kitchen/cache/cookbooks/chef-splunk/recipes/default.rb:22:in `from_file'
/tmp/kitchen/cache/cookbooks/tmg-splunk-client/recipes/default.rb:10:in `from_file'
Relevant File Content:
----------------------
/tmp/kitchen/cache/cookbooks/chef-vault/libraries/helpers.rb:
30: # +node['chef-vault']['databag_fallback']+.
31: # @example
32: # item = chef_vault_item('secrets', 'bacon')
33: # log 'Yeah buddy!' if item['_default']['type']
34: # @param [String] bag Name of the data bag to load from.
35: # @param [String] id Identifier of the data bag item to load.
36: def chef_vault_item(bag, id)
37>> if ChefVault::Item.vault?(bag, id)
38: ChefVault::Item.load(bag, id)
39: elsif node['chef-vault']['databag_fallback']
40: data_bag_item(bag, id)
41: else
42: raise "Trying to load a regular data bag item #{id} from #{bag}, and databag_fallback is disabled"
43: end
44: end
45:
46: # Helper method that allows for listing the ids of a vault in a recipe.
System Info:
------------
chef_version=16.9.20
platform=amazon
platform_version=2
ruby=ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
program_name=/opt/chef/bin/chef-client
executable=/opt/chef/bin/chef-client
Running handlers:
[2021-01-20T16:28:32+00:00] ERROR: Running exception handlers
Running handlers complete
[2021-01-20T16:28:32+00:00] ERROR: Exception handlers complete
Chef Infra Client failed. 0 resources updated in 01 seconds
[2021-01-20T16:28:32+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
[2021-01-20T16:28:32+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2021-01-20T16:28:32+00:00] FATAL: ChefVault::Exceptions::ItemNotFound: vault/splunk__default not found
If somebody is googling this. Fixed by adding the line to the kitchen.yml provisioner section:
provisioner:
data_bags_path: test/fixtures/data_bags
and placing the data_bag to test/fixtures/data_bags/vault/splunk__default.json
I'm not proficient in Ruby, but It appears that the method being used in this fallback handling (
vault?
) raises an exception that isn't handled in this helper, so instead of ever going to the "databag_falback" case it instead just hard stops and errors. The chef output in my kitchen test shows that it is resolving "chef-vault (4.0.3)".https://github.com/chef/chef-vault/blob/master/lib/chef-vault/item.rb#L320
Escalating from a comment in another issue to its own issue as it still presents on new chef versions (initially wondered if it was relevant to being on such an old release). https://github.com/chef-cookbooks/chef-vault/issues/64#issuecomment-651356201