Sha256: 064d7a60e5c7ae914be52b678ce37b45010448aee845918380632e95d12aaea8

Contents?: true

Size: 1.34 KB

Versions: 6

Compression:

Stored size: 1.34 KB

Contents

module HeadStartApp
  module Marionette

    require 'uri'
    require 'marionette/setup'
    require 'marionette/master'
    require 'marionette/puppet'
  
  
    # PuppetString class establishes a zmq messaging system connection with the puppet master
    # and sends back stats and receives instructions to execute puppet runs or ad hoc system commands.
    class Connect
      attr_accessor :uri, :connection      
  
      def initialize(options = nil)
        
        # Set default(s)
        if options.nil?

          HeadStartApp::Marionette.setup() if not File.exists? "/etc/marionette.tcp"
          options = { :uri => `cat /etc/marionette.tcp` }

        end
                
        # Set URI
        @uri = URI(options[:uri])
  
      end
      
      # Connect puppet
      # require 'zmq'
      def puppet
        require 'zmq'

        # Set ZMQ context
        context = ZMQ::Context.new(1)
  
        # Set socket to talk to master
        socket = context.socket(ZMQ::REP)
        socket.bind(@uri.to_s)
        @connection = HeadStartApp::Marionette::Puppet.new(socket)
  
      end
      
      # Connect master
      def master
        
        # socket is created within Master so Master can attempt reconnect if Puppet reboots
        @connection = HeadStartApp::Marionette::Master.new(@uri.to_s)
  
      end
      
    end
    
  end
        
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
marionette-0.0.14 lib/marionette/connect.rb
marionette-0.0.13 lib/marionette/connect.rb
marionette-0.0.12 lib/marionette/connect.rb
marionette-0.0.11 lib/marionette/connect.rb
marionette-0.0.10 lib/marionette/connect.rb
marionette-0.0.9 lib/marionette/connect.rb