Module: UmbrellioUtils::Vault

Extended by:
Vault
Included in:
Vault
Defined in:
lib/umbrellio_utils/vault.rb

Instance Method Summary collapse

Instance Method Details

#create_kv_engine(path) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/umbrellio_utils/vault.rb', line 11

def create_kv_engine(path)
  ::Vault.logical.write(
    "sys/mounts/#{path}",
    config: {},
    generate_signing_key: true,
    options: { version: 2 },
    path: path.to_s,
    type: "kv",
  )
end

#secret_engine_present?(engine_path) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/umbrellio_utils/vault.rb', line 7

def secret_engine_present?(engine_path)
  ::Vault.logical.read("sys/mounts").data.key?(:"#{engine_path}/")
end

#write_to_kv(engine_path:, secret_path:, data:) ⇒ Object



22
23
24
25
26
27
# File 'lib/umbrellio_utils/vault.rb', line 22

def write_to_kv(engine_path:, secret_path:, data:)
  full_data_path = File.join(engine_path, "data", secret_path)
  full_meta_path = File.join(engine_path, "metadata", secret_path)
  ::Vault.logical.write(full_data_path, data:)
  ::Vault.logical.write(full_meta_path, id: secret_path, max_versions: 1, cas_required: false)
end