Hi Martin,
Il giorno 13/mag/2016, alle ore 09:36, Martin Alfke <
tux...@gmail.com> ha scritto:
> The Ruby part must be a function - like in the example you provided in your first email.
> You can then use the function inside your manifest.
>
> Functions are always executed on the Master.
After a couple of try, i understood it.
for anyone looking at the same solution, my code:
manifest:
$masterenvpath = print_environmentpath()
$path = "${masterenvpath}/${::environment}/modules/braveconf/files/puppet/puppet.conf-${::hostname}"
if ( file_exists ("${path}") == 1 ) {
function:
lib/puppet/parser/functions/print_environmentpath.rb
require"puppet"
module Puppet::Parser::Functions
newfunction(:print_environmentpath, :type => :rvalue) do |args|
Puppet.initialize_settings unless Puppet[:environmentpath]
path = Puppet[:environmentpath]
if File.exists?(path)
path
else
nil
end
end
end
Thank you very much Martin!
Daniele