Created
May 14, 2014 10:16
-
-
Save johnfitzpatrick/65a73e157ca91be9dc7b to your computer and use it in GitHub Desktop.
Ohai module refactor in Chef Intermediate class
This file contains 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
Ohai.plugin(:Apache) do | |
provides "apache/modules" | |
collect_data(:default) do | |
apache Mash.new | |
apache[:modules] = {:static => [], :shared => []} | |
modules = shell_out("apachectl -t -D DUMP_MODULES") | |
modules.stdout.each_line do |line| | |
fullkey, value = line.split(/\(/, 2).map {|i| i.strip} | |
apache_mod = fullkey.gsub(/_module/,"") | |
dso_type = value.to_s.chomp("\)") | |
if dso_type.match(/shared/) | |
apache[:modules][:shared] << apache_mod | |
elsif dso_type.match(/static/) | |
apache[:modules][:static] << apache_mod | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment