Class: Ronin::Chef
- Inherits:
-
Object
- Object
- Ronin::Chef
- Defined in:
- lib/ronin/chef.rb
Instance Method Summary collapse
- #clean_up ⇒ Object
- #create_run_list ⇒ Object
- #create_solo_conf ⇒ Object
-
#initialize ⇒ Chef
constructor
A new instance of Chef.
- #run ⇒ Object
Constructor Details
Instance Method Details
#clean_up ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/ronin/chef.rb', line 63 def clean_up Ronin::Log.info("Cleaning up Chef run list at #{@run_list}.") File.delete(@run_list) Ronin::Log.info("Cleaning up Chef-Solo config at #{@solo_conf}.") File.delete(@solo_conf) end |
#create_run_list ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ronin/chef.rb', line 30 def create_run_list Ronin::Log.info("Building Chef run list at #{@run_list}.") @rl = [] @rl_obj = {} @recipes.each do |r| @rl << "recipe[#{r}]" Ronin::Log.info("Adding recipe '#{r}' to run list.") end @rl_obj['run_list'] = @rl File.open(@run_list, "w") do |f| f.write(@rl_obj.to_json) end end |
#create_solo_conf ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/ronin/chef.rb', line 55 def create_solo_conf @solo_config = "file_cache_path '/var/tmp/ronin/chef-solo'\ncookbook_path '#{Ronin::Config[:artifact_path]}'\n" File.open(@solo_conf, "w") do |f| f.write(@solo_config) end end |
#run ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/ronin/chef.rb', line 46 def run self.create_run_list self.create_solo_conf Ronin::Log.info("Running Chef, logging to #{Ronin::Config[:interpreter_log_path]}/ronin-chef.log.") @cmd = Mixlib::ShellOut.new("#{Ronin::Util.find_cmd("chef-solo")} --logfile #{Ronin::Config[:log_path]}/ronin-chef.log --config #{@solo_conf} --json-attributes #{@run_list}") @cmd.run_command self.clean_up end |