[chef] Re: Listing chef-installed software packages


Chronological Thread 
  • From: Lee Maguire < >
  • To:
  • Subject: [chef] Re: Listing chef-installed software packages
  • Date: Tue, 05 Jul 2011 16:31:39 +0100


> aha.. then its easy, you can use any report handlers, the report method 
> invoked with a run_status object which contain updated_resources object, 
> which is actually a  resource collection; you can use this collection 
> and filter out only the packages that are updated or installed.

So the only way to access this information is adding report handlers to
client.rb - it can't be done from within cookbooks?

I'm trying to automatically populate the deborphan "keep" file with
packages that have been installed by chef.

----------------------------------
module Deborphan
  class Keep < ::Chef::Handler
    attr_reader :config
    def initialize(config={})
        @config = config
        @config[:keepfile] ||= "/var/lib/deborphan/keep"
    end
    def report
      File.open(config[:keepfile],'w') do |keep|
        run_status.all_resources.each do |r|
          if (r.resource_name.to_s == 'package') && (r.action.to_s ==
'install' ) then
            keep.puts r.package_name.to_s
          end
        end
      end
    end
  end
end





Archive powered by MHonArc 2.6.16.

§