Created
October 14, 2015 10:08
-
-
Save hashbrowncipher/4b107ff0d518d521be20 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Whoa!