Puppet Function: deploy_application_configs_to_files

Defined in:
lib/puppet/parser/functions/deploy_application_configs_to_files.rb
Function type:
Ruby 3.x API

Overview

deploy_application_configs_to_files()Any

Convert deploy::application::configs to files hash

Returns:

  • (Any)


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

newfunction(:deploy_application_configs_to_files, :type => :rvalue, :doc => <<-EOS
  Convert deploy::application::configs to files hash
EOS
) do |args|
  args.length == 2 or raise Puppet::ParseError.new("deploy_application_configs_to_files takes 2 arguments!")

  path_prefix = args[0].to_s
  hash_to_convert = args[1]

  hash_to_convert.is_a?(Hash) or raise Puppet::ParseError.new("deploy_application_configs_to_files last agrument must be Hash, was #{hash_to_convert.inspect}")

  files_hash = {}

  hash_to_convert.each do |k,value|
    path = k.split("/")
    if path.size > 1
      files_hash["#{path_prefix}/#{path.first}"] = {
        :ensure => 'directory'
      }
    end
    files_hash["#{path_prefix}/#{path.join("/")}"] = {
      :content => value.to_s
    }
  end

  files_hash
end