lib/modulesync.rb in modulesync-2.4.0 vs lib/modulesync.rb in modulesync-2.5.0

- old
+ new

@@ -29,11 +29,17 @@ def self.options @options end def self.local_file(config_path, file) - File.join(config_path, MODULE_FILES_DIR, file) + path = File.join(config_path, MODULE_FILES_DIR, file) + if !File.exist?("#{path}.erb") && File.exist?(path) + $stderr.puts "Warning: using '#{path}' as template without '.erb' suffix" + path + else + "#{path}.erb" + end end # List all template files. # # Only select *.erb files, and strip the extension. This way all the code will only have to handle bare paths, @@ -86,21 +92,22 @@ configs = settings.build_file_configs(filename) target_file = puppet_module.path(filename) if configs['delete'] Renderer.remove(target_file) else - templatename = local_file(options[:configs], filename) + template_file = local_file(options[:configs], filename) begin - erb = Renderer.build(templatename) + erb = Renderer.build(template_file) # Meta data passed to the template as @metadata[:name] metadata = { :module_name => settings.additional_settings[:puppet_module], :namespace => settings.additional_settings[:namespace], :workdir => puppet_module.working_directory, :target_file => target_file, } template = Renderer.render(erb, configs, metadata) - Renderer.sync(template, target_file) + mode = File.stat(template_file).mode + Renderer.sync(template, target_file, mode) rescue StandardError $stderr.puts "#{puppet_module.given_name}: Error while rendering file: '#{filename}'" raise end end