Lechucico
Lechucico

Reputation: 2102

Chef: Vault Hashicorp ruby gem

I'm trying to use the vault gem on my chef recipe.

I'm importing it on my `metadata.rb

gem vault

Then on my recipe default.rb

Vault.configure do |config|
  config.address = "http://127.0.0.1:8200"
  config.token = "token"
end

secret = Vault.logical.read("secret/stripe")
stripe_key = secret.data[:api_key]

But an error raises:

uninitialized constant #<Class:#<Chef::Recipe:0x00000000036346a8>>::Vault
14>> Vault.configure do |config|

What i'm missing?

Upvotes: 0

Views: 715

Answers (1)

bitsapien
bitsapien

Reputation: 1833

You will have to do require 'vault' on the top of your default.rb file. That way the Vault constant will be made available to your recipe.

Upvotes: 3

Related Questions