Search code examples
chef-infrachef-recipecookbook

How do I search for a vault item from inside a recipe?


I have a vault item that looks like this:

{
  "id": "myvaultitem",
  "username": "myuser",
  "password": "mypass"
}

How can I grab a vault in a recipe that matches username:myuser? Could I do a wildcard search to load all vaults matching id:my*?

Of course I can search with knife, but I want to do this via a recipe.


Solution

  • You access vault items via the chef_vault_item() API. You can't search values like that as they are encrypted server side.