Sha256: 7be3716ff033bf9aaabc8ed5ba5f7504146b71825df14539582c3cdce2199a82

Contents?: true

Size: 1.42 KB

Versions: 2

Compression:

Stored size: 1.42 KB

Contents

module Sprinkle
  module Actors
    # = Local Delivery Method
    #
    # This actor implementation performs any given commands on your local system, as
    # opposed to other implementations that generally run commands on a remote system
    # via the network.
    #
    # This is useful if you'd like to use Sprinkle to provision your local machine. 
    # To enable this actor, in your Sprinkle script specify the :local delivery mechanism. 
    #
    #   deployment do
    #     delivery :local
    #   end
    #
    # Note, your local machine will be assumed to be a member of all roles when applying policies
    #
    class Local
      
      def process(name, commands, roles, suppress_and_return_failures = false) #:nodoc:
        commands.each do |command|
          system command
          return false if $?.to_i != 0
        end
        return true
      end            
      
      def put(name, uploads, roles, suppress_and_return_failures = false)
        uploads.each do |file, content|               
          retried = false
          begin   
            File.open(file, "w+") { |fp| fp << content }
          rescue Errno::ENOENT
            FileUtils.mkdir_p(File.dirname(file))
            if retried == false
              retried = true
              retry 
            end     
          end
        end

        return true
      end
      
      def find_servers(role)
        ['localhost']
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jemmyw-sprinkle-0.2.3 lib/sprinkle/actors/local.rb
jemmyw-sprinkle-0.2.4 lib/sprinkle/actors/local.rb