1
0
mirror of https://github.com/jordansissel/fpm synced 2024-12-22 00:34:15 +01:00
fpm/templates/puppet/package.pp.erb
Jordan Sissel 710fe90df0 - refactor to allow package targets to override generate_specfile so
puppet target can write multiple files (::package class and anticlass).
2011-06-20 19:26:43 -07:00

35 lines
925 B
Plaintext

# TODO(sissel): implement 'anti' class for this package.
class <%= name %>::package {
$version = "<%= version %>"
$iteration = "<%= iteration %>"
file {
<% paths.each do |path|
stat = File.lstat(path)
params = {}
if stat.directory?
params[:ensure] = "directory"
elsif stat.symlink?
params[:ensure] = "link"
params[:target] = File.readlink(path)
stat = File.stat(path)
else
params[:ensure] = "file"
params[:source] = "puppet:///modules/#{name}/#{path}"
end
if params[:ensure] != "link"
params[:owner] = uid2user(stat.uid)
params[:group] = gid2group(stat.gid)
params[:mode] = sprintf("%04o", stat.mode & 0777)
end
settings = puppetsort(params).collect { |k,v| "#{k} => \"#{v}\"" }.join(",\n ")
-%>
# <%= stat.inspect %>
"<%= fixpath(path) %>":
<%= settings %>;
<% end # paths.each -%>
}
}