lib/marionette/puppet.rb in marionette-0.0.11 vs lib/marionette/puppet.rb in marionette-0.0.12

- old
+ new

@@ -1,19 +1,19 @@ module HeadStartApp module Marionette require 'uri' - require 'facter' # Puppet class is the active ZMQ connection on the puppet node class Puppet attr_accessor :socket, :thread, :message def initialize(socket) @socket = socket + @messages = [] start end # Starts send and response thread @@ -31,11 +31,11 @@ # Stand by for a response msg @response = @socket.recv # Sets default message to current time - @message = "Response from node @ #{Time.now}." + @message << "Response from node @ #{Time.now}." begin # Execute a puppet run and/or ad hoc system commands @response = Marshal.load(@response) @@ -50,11 +50,11 @@ end # Send back system stats # @socket.send Marshal.dump(stats) - @socket.send Marshal.dump(@message) + @socket.send Marshal.dump(@messages) end # Fetches thread status def status @@ -74,21 +74,21 @@ end # Executes ad hoc system command msg'd from the master def system_run - system "#{@response[:system][:command]}" + @message << `#{@response[:system][:command]}` end # Executes a puppet run def puppet_run if @response[:puppet].nil? - system "puppet agent --server master.runrails.com --verbose --waitforcert 5 --no-daemonize --onetime --logdest /var/log/puppet.log" + @message << `puppet agent --server master.runrails.com --verbose --waitforcert 5 --no-daemonize --onetime --logdest /var/log/puppet.log` else - system "puppet #{@response[:puppet][:args]}" + @message << `puppet agent #{@response[:puppet][:args]}` end end # Fetches facts collection @@ -96,10 +96,10 @@ # Load facts from cli to reduce ruby memory footprint facts = `facter` facts = facts.split "\n" facts.collect! {|f| ff=f.split("=>"); {ff[0].strip.to_sym => ff[1]}}.compact - @message = facts + @message << facts end end