You may need to create a custom fact to determine the environment when the agent runs. For example, here's a custom fact that reads the environment from a file.
Facter.add("environment") do setcode do Facter::Util::Resolution.exec('/bin/cat /usr/local/etc/environment') end end Your site manifest can also be set to update the file contents when it runs. On Monday, May 9, 2016 at 9:45:38 AM UTC-4, Daniele Palumbo wrote: > > Hi, > > i need to check if a file exists on the puppet master. > > No big deal: > > http://stackoverflow.com/questions/18784329/how-to-test-for-existence-of-a-file-on-the-puppet-master > > > So i made: > -- > cat ./modules/braveconf/lib/puppet/parser/functions/file_exists.rb > require"puppet" > module Puppet::Parser::Functions > newfunction(:file_exists, :type => :rvalue) do |args| > if File.exists?(args[0]) > return 1 > else > return 0 > end > end > end > -- > > Now, my problem is about path. > > Since i have environmentpath, as seen is > puppet config print environmentpath --section master --environment > development > /etc/puppetlabs/code/environments > > I would like to use, in the manifest: > -- > if ( file_exists > ("${::environmentpath}/${::environment}/modules/module/files/configfile-${::hostname}") > > == 1 ) { > -- > > But ${::environmentpath} is empty. > > How can i manage this topic, avoiding to hardcode > /etc/puppetlabs/code/environments in the code? > Is there a way to get variable from puppet master config? > > Thanks, > 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/9b1f21ea-a95c-4bd3-a44d-8ba85b32a636%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.