From e3abcd6b5330959016b43115a8bf1b1cef668d30 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Mon, 20 Jul 2015 16:18:52 -0400 Subject: Add package_manifest resource. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch converts the write_package_names function into a proper resource. Using the write_package_names only works if the function comes last in the puppet manifest. By making the same functionality a custom resource we allow for it to exist anywhere in the manifest and provide the same functionality. The new syntax would be: package_manifest{'/tmp/foo': ensure => present} Co-Authored-By: Martin Mágr Change-Id: If3e03b1983fed47082fac8ce63f975557dbc503c --- lib/puppet/parser/functions/write_package_names.rb | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 lib/puppet/parser/functions/write_package_names.rb (limited to 'lib/puppet/parser/functions') diff --git a/lib/puppet/parser/functions/write_package_names.rb b/lib/puppet/parser/functions/write_package_names.rb deleted file mode 100644 index 8f99674..0000000 --- a/lib/puppet/parser/functions/write_package_names.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'fileutils' - -module Puppet::Parser::Functions - newfunction(:write_package_names, :doc => "Write package names which are managed via this puppet run to a file.") do |arg| - if arg[0].class == String - begin - output_file = arg[0] - packages = catalog.resources.collect { |r| r.title if r.type == 'Package' }.compact - FileUtils.mkdir_p(File.dirname(output_file)) - File.open(output_file, 'w') do |f| - packages.each do |pkg_name| - f.write(pkg_name + "\n") - end - end - rescue JSON::ParserError - raise Puppet::ParseError, "Syntax error: #{arg[0]} is invalid" - end - else - raise Puppet::ParseError, "Syntax error: #{arg[0]} is not a String" - end - end -end -- cgit 1.2.3-korg