Class: Pipely::Deploy::BootstrapContext

Inherits:
Object
  • Object
show all
Defined in:
lib/pipely/deploy/bootstrap_context.rb

Overview

Context passed to the erb templates, providers helpers for common bootstraping activities for emr and ec2 instances.

bootstrap.ec2.install_gems_script
bootstrap.emr.install_gems_script

Defined Under Namespace

Classes: Ec2Context, EmrContext

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBootstrapContext

Returns a new instance of BootstrapContext.



71
72
73
74
# File 'lib/pipely/deploy/bootstrap_context.rb', line 71

def initialize
  @emr = EmrContext.new(self)
  @ec2 = Ec2Context.new(self)
end

Instance Attribute Details

#ec2Object (readonly)

Returns the value of attribute ec2.



13
14
15
# File 'lib/pipely/deploy/bootstrap_context.rb', line 13

def ec2
  @ec2
end

#emrObject (readonly)

Returns the value of attribute emr.



13
14
15
# File 'lib/pipely/deploy/bootstrap_context.rb', line 13

def emr
  @emr
end

#gem_filesObject

Returns the value of attribute gem_files.



12
13
14
# File 'lib/pipely/deploy/bootstrap_context.rb', line 12

def gem_files
  @gem_files
end

#s3_steps_pathObject

Returns the value of attribute s3_steps_path.



12
13
14
# File 'lib/pipely/deploy/bootstrap_context.rb', line 12

def s3_steps_path
  @s3_steps_path
end

Instance Method Details

#fetch_command(transport) ⇒ Object



76
77
78
79
80
81
82
83
# File 'lib/pipely/deploy/bootstrap_context.rb', line 76

def fetch_command(transport)
  case transport.to_sym
  when :hadoop_fs
    'hadoop fs -copyToLocal'
  when :awscli
    'aws s3 cp'
  end
end

#install_gems_script(transport, &blk) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/pipely/deploy/bootstrap_context.rb', line 85

def install_gems_script(transport, &blk)

  transport_cmd = fetch_command(transport)

  if transport_cmd.nil?
    raise "Unsupported transport: #{transport}" unless blk
  end

  script = ""
  @gem_files.each do |gem_file|
    filename = File.basename(gem_file)
    params = [transport_cmd, gem_file, filename]
    if blk
      command = yield(*params)
    else
      command = params.join(" ")
    end

    script << %Q[
# #{filename}
#{command}
gem install --force --local #{filename} --no-ri --no-rdoc
]
  end

  script
end