Skip to content

Instantly share code, notes, and snippets.

@hashbrowncipher
Created October 14, 2015 10:08
Show Gist options
  • Select an option

  • Save hashbrowncipher/4b107ff0d518d521be20 to your computer and use it in GitHub Desktop.

Select an option

Save hashbrowncipher/4b107ff0d518d521be20 to your computer and use it in GitHub Desktop.
require 'puppet/file_serving/metadata'
require 'puppet/type'
def generate
existing_files = Puppet::FileServing::Metadata.indirection.search(path, :recurse=>:true).each { |f|
full_path = ::File.join(base, relative_path)
}.to_set
# TODO: replace this code with something better. At least match start of line, please.
packaged_resources = `fgrep -h "#{dirname}/" /var/lib/dpkg/info/*.list`.split.to_set
nonpackaged_files = (existing_files - packaged_resources)
nonpackaged_files.each { |f|
resource = Puppet::Type.type('file').new(full_path)
#TODO: this is supposed to prevent emission of file resources already in the catalog. Does it?
next if resource[:source]
resource[:ensure] = :absent
resource[:noop] = true
resource
end
end
@solarkennedy
Copy link

Whoa!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment