Method: Bolt::ModuleInstaller::Puppetfile#write

Defined in:
lib/bolt/module_installer/puppetfile.rb

#write(path, moduledir = nil) ⇒ Object

Writes a Puppetfile that includes specifications for each of the modules.



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/bolt/module_installer/puppetfile.rb', line 71

def write(path, moduledir = nil)
  File.open(path, 'w') do |file|
    if moduledir
      file.puts "# This Puppetfile is managed by Bolt. Do not edit."
      file.puts "# For more information, see https://pup.pt/bolt-modules"
      file.puts
      file.puts "# The following directive installs modules to the managed moduledir."
      file.puts "moduledir '#{moduledir.basename}'"
      file.puts
    end

    @modules.each { |mod| file.puts mod.to_spec }
  end
rescue SystemCallError => e
  raise Bolt::FileError.new(
    "#{e.message}: unable to write Puppetfile.",
    path
  )
end