Sha256: 5d355bd8d3355ba147ba971495d03a74b55d4a89b2c677c12261619b8dfcc021

Contents?: true

Size: 757 Bytes

Versions: 71

Compression:

Stored size: 757 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)
    # Send Analytics Report
    Puppet.lookup(:bolt_executor) {}&.report_function_call(self.class.name)

    File.write(filename, content)
    nil
  end
end

Version data entries

71 entries across 71 versions & 1 rubygems

Version Path
bolt-4.0.0 bolt-modules/file/lib/puppet/functions/file/write.rb
bolt-3.29.0 bolt-modules/file/lib/puppet/functions/file/write.rb
bolt-3.28.0 bolt-modules/file/lib/puppet/functions/file/write.rb
bolt-3.27.4 bolt-modules/file/lib/puppet/functions/file/write.rb
bolt-3.27.2 bolt-modules/file/lib/puppet/functions/file/write.rb
bolt-3.27.1 bolt-modules/file/lib/puppet/functions/file/write.rb
bolt-3.26.2 bolt-modules/file/lib/puppet/functions/file/write.rb
bolt-3.26.1 bolt-modules/file/lib/puppet/functions/file/write.rb
bolt-3.25.0 bolt-modules/file/lib/puppet/functions/file/write.rb
bolt-3.24.0 bolt-modules/file/lib/puppet/functions/file/write.rb
bolt-3.23.1 bolt-modules/file/lib/puppet/functions/file/write.rb
bolt-3.23.0 bolt-modules/file/lib/puppet/functions/file/write.rb
bolt-3.22.1 bolt-modules/file/lib/puppet/functions/file/write.rb
bolt-3.22.0 bolt-modules/file/lib/puppet/functions/file/write.rb
bolt-3.21.0 bolt-modules/file/lib/puppet/functions/file/write.rb
bolt-3.20.0 bolt-modules/file/lib/puppet/functions/file/write.rb
bolt-3.19.0 bolt-modules/file/lib/puppet/functions/file/write.rb
bolt-3.18.0 bolt-modules/file/lib/puppet/functions/file/write.rb
bolt-3.17.0 bolt-modules/file/lib/puppet/functions/file/write.rb
bolt-3.16.1 bolt-modules/file/lib/puppet/functions/file/write.rb