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

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/C86CAE7A-3FE7-4C9E-94D1-D96E59C3C0B7%40retaggio.net.
For more options, visit https://groups.google.com/d/optout.

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to