Permalink
Browse files

- refactor to allow package targets to override generate_specfile so

  puppet target can write multiple files (::package class and anticlass).
  • Loading branch information...
1 parent a91dc22 commit a7d2771295d8ec3b644c3eff6f2939b4610fdddc @jordansissel committed Jun 21, 2011
Showing with 45 additions and 0 deletions.
  1. +34 −0 templates/puppet/package.pp.erb
  2. +11 −0 templates/puppet/package/remove.pp.erb
View
34 templates/puppet/package.pp.erb
@@ -0,0 +1,34 @@
+# 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 -%>
+ }
+}
View
11 templates/puppet/package/remove.pp.erb
@@ -0,0 +1,11 @@
+class <%= name %>::package::remove {
+ $version = "<%= version %>"
+ $iteration = "<%= iteration %>"
+
+ file {
+<% paths.each do |path| -%>
+ "<%= fixpath(path) %>":
+ <%= settings %>;
+<% end # paths.each -%>
+ }
+}

0 comments on commit a7d2771

Please sign in to comment.