module Vaml

Constants

VERSION

Attributes

configuration[RW]

Public Class Methods

add_policy(policy_name, policy_definition) click to toggle source

policy = <<-EOH

path "sys" {
  policy = "deny"
}

EOH Vault.sys.put_policy(“dev”, policy)

# File lib/vaml.rb, line 69
def add_policy(policy_name, policy_definition)
  Vault.sys.put_policy(policy_name, policy_definition)
end
auth_with_github(token) click to toggle source
# File lib/vaml.rb, line 59
def auth_with_github(token)
  Vaml::Github.auth(token)
end
configure(options) { |configuration| ... } click to toggle source

@param [Hash] options {host: '0.0.0.0:8200', token: ENV, organization: ''}

# File lib/vaml.rb, line 16
def configure(options)
  options[:host] ||= 'http://127.0.0.1:8200'
  options[:token] ||= ENV['VAULT_TOKEN']
  options[:ssl_verify] ||= false

  self.configuration ||= Configuration.new(options)
  yield configuration if block_given?

  # Configures Vault itself.
  Vaml::VaultConfig.configure!
  self
end
from_yaml(yml) click to toggle source
# File lib/vaml.rb, line 37
def from_yaml(yml)
  handler = Vaml::ConfigHandler.new
  parser = Psych::Parser.new(handler)
  parser.parse(yml)
  handler.root.to_ruby.first
end
list_policies() click to toggle source
# File lib/vaml.rb, line 73
def list_policies
  Vault.sys.policies.map do |name|
    Vault.sys.policy(name)
  end
end
read(query) click to toggle source
# File lib/vaml.rb, line 44
def read(query)
  Vault.with_retries(Vault::HTTPConnectionError) do
    val = Vault.logical.read(query)
    raise "VamlError: No secret was stored for #{query}" unless val
    val
  end
end
read_string(key) click to toggle source
# File lib/vaml.rb, line 33
def read_string(key)
  read(key).data[:value]
end
write(key, value) click to toggle source
# File lib/vaml.rb, line 53
def write(key, value)
  Vault.with_retries(Vault::HTTPConnectionError) do
    Vault.logical.write(key, value)
  end
end
write_string(key, value) click to toggle source
# File lib/vaml.rb, line 29
def write_string(key, value)
  write(key, {value: value})
end