class FPM::Package::Puppet
Public Instance Methods
architecture()
click to toggle source
# File lib/fpm/package/puppet.rb, line 9 def architecture case @architecture when nil, "native" @architecture = %x{uname -m}.chomp end return @architecture end
build!(params)
click to toggle source
# File lib/fpm/package/puppet.rb, line 52 def build!(params) # TODO(sissel): Support these somehow, perhaps with execs and files. self.scripts.each do |name, path| case name when "pre-install" when "post-install" when "pre-uninstall" when "post-uninstall" end # case name end # self.scripts.each if File.exists?(params[:output]) # TODO(sissel): Allow folks to choose output? logger.error("Puppet module directory '#{params[:output]}' already " \ "exists. Delete it or choose another output (-p flag)") end ::Dir.mkdir(params[:output]) builddir = ::Dir.pwd # Copy 'files' from builddir to :output/files Find.find("files", "manifests") do |path| logger.info("Copying path: #{path}") if File.directory?(path) ::Dir.mkdir(File.join(params[:output], path)) else FileUtils.cp(path, File.join(params[:output], path)) end end end
default_output()
click to toggle source
The directory we create should just be the name of the package as the module name
# File lib/fpm/package/puppet.rb, line 85 def default_output name end
generate_specfile(builddir)
click to toggle source
Default specfile generator just makes one specfile, whatever that is for this package.
# File lib/fpm/package/puppet.rb, line 19 def generate_specfile(builddir) paths = [] logger.info("PWD: #{File.join(builddir, unpack_data_to)}") fileroot = File.join(builddir, unpack_data_to) Dir.chdir(fileroot) do Find.find(".") do |p| next if p == "." paths << p end end logger.info(paths[-1]) manifests = %w{package.pp package/remove.pp} ::Dir.mkdir(File.join(builddir, "manifests")) manifests.each do |manifest| dir = File.join(builddir, "manifests", File.dirname(manifest)) logger.info("manifests targeting: #{dir}") ::Dir.mkdir(dir) if !File.directory?(dir) File.open(File.join(builddir, "manifests", manifest), "w") do |f| logger.info("manifest: #{f.path}") template = template(File.join("puppet", "#{manifest}.erb")) ::Dir.chdir(fileroot) do f.puts template.result(binding) end end end end
gid2group(gid)
click to toggle source
Helper for group lookup
# File lib/fpm/package/puppet.rb, line 109 def gid2group(gid) begin grent = Etc.getgrgid(gid) return grent.name rescue ArgumentError => e # Invalid user id? No user? Return the uid. logger.warn("Failed to find group for gid #{gid}") return gid.to_s end end
puppetsort(hash)
click to toggle source
This method is used by the puppet manifest template
# File lib/fpm/package/puppet.rb, line 90 def puppetsort(hash) # TODO(sissel): Implement sorting that follows the puppet style guide # Such as, 'ensure' goes first, etc. return hash.to_a end
uid2user(uid)
click to toggle source
Helper for user lookup
# File lib/fpm/package/puppet.rb, line 97 def uid2user(uid) begin pwent = Etc.getpwuid(uid) return pwent.name rescue ArgumentError => e # Invalid user id? No user? Return the uid. logger.warn("Failed to find username for uid #{uid}") return uid.to_s end end
unpack_data_to()
click to toggle source
# File lib/fpm/package/puppet.rb, line 48 def unpack_data_to "files" end