Puppet Function: file_on_server
- Defined in:
- lib/puppet/parser/functions/file_on_server.rb
- Function type:
- Ruby 3.x API
Overview
This function returns the content of a file found on the puppet master.
Examples:
file_on_server('/secrets/myfile')
Would return whatever was contained within /secrets/myfile on the puppet master
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/puppet/parser/functions/file_on_server.rb', line 6 newfunction(:file_on_server, :type => :rvalue, :doc => <<-EOS This function returns the content of a file found on the puppet master. *Examples:* file_on_server('/secrets/myfile') Would return whatever was contained within /secrets/myfile on the puppet master EOS ) do |arguments| if (arguments.size != 1) then raise(Puppet::ParseError, "file_on_server(): Wrong number of arguments "+ "given #{arguments.size} for 1") end contents = File.open(arguments[0], 'rb') { |f| f.read } return contents end |