Sha256: 5c749b6ea656045b3aecc3be9a263245c1a24fc83a31305924951c9d48e2ecd3

Contents?: true

Size: 1.33 KB

Versions: 16

Compression:

Stored size: 1.33 KB

Contents

require 'erb'
require 'ostruct'

module Mccloud
  module Provisioner

    class Shell

      attr_reader   :name
      attr_reader   :env

      attr_accessor :path
      attr_accessor :inline
      attr_accessor :sudo

      def initialize(env)
        @env=env
        @sudo=false
        @name ="shell"
        @inline="who am i"
        @log_level="info"
      end

      def run(server)
        server.transfer(StringIO.new(@inline),"/tmp/shell-provisioner.sh") unless @inline.nil?
        server.transfer(path,"/tmp/shell-provisioner.sh") unless @path.nil?

        server.execute("chmod +x /tmp/shell-provisioner.sh",{:mute => true})

                env.ui.info "[#{server.name}] - [#{@name}] - running shell"
                env.ui.info "[#{server.name}] - [#{@name}] - login as #{server.user}"

                begin
                  if !@sudo || server.user=="root"
                    server.execute("/tmp/shell-provisioner.sh")
                  else
                    server.execute("sudo /tmp/shell-provisioner.sh")
                  end
                rescue Exception
                ensure
                  env.ui.info "[#{server.name}] - [#{@name}] - Cleaning up script"
                  server.execute("rm /tmp/shell-provisioner.sh",{:mute => true})
                end
      end

    end
  end #Module Provisioners
end #Module Mccloud

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
mccloud-0.1.1 lib/mccloud/provisioner/shell.rb
mccloud-0.0.28 lib/mccloud/provisioner/shell.rb
mccloud-0.0.27 lib/mccloud/provisioner/shell.rb
mccloud-0.0.26 lib/mccloud/provisioner/shell.rb
mccloud-0.0.25 lib/mccloud/provisioner/shell.rb
mccloud-0.0.24 lib/mccloud/provisioner/shell.rb
mccloud-0.0.23 lib/mccloud/provisioner/shell.rb
mccloud-0.0.22 lib/mccloud/provisioner/shell.rb
mccloud-0.0.21 lib/mccloud/provisioner/shell.rb
mccloud-0.0.20 lib/mccloud/provisioner/shell.rb
mccloud-0.0.19 lib/mccloud/provisioner/shell.rb
mccloud-0.0.18 lib/mccloud/provisioner/shell.rb
mccloud-0.0.17 lib/mccloud/provisioner/shell.rb
mccloud-0.0.16 lib/mccloud/provisioner/shell.rb
mccloud-0.0.15 lib/mccloud/provisioner/shell.rb
mccloud-0.0.14 lib/mccloud/provisioner/shell.rb