Puppet Function: configvault_list

Defined in:
lib/puppet/functions/configvault_list.rb
Function type:
Ruby 4.x API

Overview

configvault_list(String $key, Optional[Boolean] $public, Optional[String] $bucket, Optional[String] $binfile)Array

Parameters:

  • key (String)
  • public (Optional[Boolean])
  • bucket (Optional[String])
  • binfile (Optional[String])

Returns:

  • (Array)


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/puppet/functions/configvault_list.rb', line 3

Puppet::Functions.create_function(:'configvault_list') do
  dispatch :list do
    param 'String', :key
    optional_param 'Boolean', :public
    optional_param 'String', :bucket
    optional_param 'String', :binfile
    return_type 'Array'
  end

  def list(key, is_public = true, user = nil, bucket = nil, binfile = nil)
    bucket ||= lookup('configvault::bucket')
    binfile ||= lookup('configvault::binfile')

    args = [binfile, 'list', bucket, key]
    args << '--private' unless is_public
    stdout, stderr, status = Open3.capture3(*args)
    fail('Configvault failed: ' + stderr) unless status.success?
    stdout.split("\n")
  end

  def lookup(key)
    Puppet::Pops::Lookup.lookup(key, nil, nil, false, nil, Puppet::Pops::Lookup::Invocation.new(closure_scope, {}, {}))
  end
end