- Clone git repository:
git clone [email protected]:stenio123/vault-ruby.git
- Move to desired branch:
git checkout added-namespaces
- Create gem:
gem build vault.gemspec
- Install gem:
gem install ./vault-0.12.1.gem
- Create test code:
# test.rb
require 'vault'
vault_client = Vault::Client.new(address: ENV["VAULT_ADDR"], token: ENV["VAULT_ADDR"], namespace: ENV["VAULT_NAMESPACE"])
# Edit the secret path as needed
secret = Vault.logical.read("secret/app1")
puts secret.data
- Set environment variables accordingly:
export VAULT_ADDR=YOUR-VAULT-ADDRESS
# Note that the ruby gem can also look for the Vault token in ~/.vault-token if this env var is not set
export VAULT_TOKEN=YOUR-VAULT-TOKEN
export VAULT_NAMESPACE=YOUR-VAULT-NAMESPACE
- Run the test code:
ruby test.rb
# Output:
{:test=>"secret"}