Sha256: 4217bad3e251913348a9dc60fe73abd887fb28ac90bbb6038b5ed793a8f24442

Contents?: true

Size: 728 Bytes

Versions: 7

Compression:

Stored size: 728 Bytes

Contents

# frozen_string_literal: true

# Write a string to a file on localhost using ruby's `File.write`. This will
# only write files to the machine you run Bolt on. Use `write_file()` to write
# to remote targets.
Puppet::Functions.create_function(:'file::write') do
  # @param filename Absolute path.
  # @param content File content to write.
  # @example Write a file to disk
  #   file::write('C:/Users/me/report', $apply_result.first.report)
  dispatch :write do
    required_param 'String', :filename
    required_param 'String', :content
    return_type 'Undef'
  end

  def write(filename, content)
    Puppet.lookup(:bolt_executor) {}&.report_function_call(self.class.name)
    File.write(filename, content)
    nil
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
bolt-2.15.0 bolt-modules/file/lib/puppet/functions/file/write.rb
bolt-2.14.0 bolt-modules/file/lib/puppet/functions/file/write.rb
bolt-2.13.0 bolt-modules/file/lib/puppet/functions/file/write.rb
bolt-2.12.0 bolt-modules/file/lib/puppet/functions/file/write.rb
bolt-2.11.1 bolt-modules/file/lib/puppet/functions/file/write.rb
bolt-2.11.0 bolt-modules/file/lib/puppet/functions/file/write.rb
bolt-2.10.0 bolt-modules/file/lib/puppet/functions/file/write.rb