class Pipely::Deploy::BootstrapContext::Ec2Context
Context for EC2 instances
Public Class Methods
new(parent)
click to toggle source
# File lib/pipely/deploy/bootstrap_context.rb, line 28 def initialize(parent) @parent = parent @ssh_initialized = false end
Public Instance Methods
as_root(init_ssh=true) { || ... }
click to toggle source
# File lib/pipely/deploy/bootstrap_context.rb, line 37 def as_root(init_ssh=true) script = "" if init_ssh && !@ssh_initialized @ssh_initialized = true script << %{ # Set up ssh access if [ ! -f ~/.ssh/id_rsa ]; then mkdir -p ~/.ssh ssh-keygen -P '' -f ~/.ssh/id_rsa cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys chmod 600 ~/.ssh/authorized_keys fi } end script << %{ # Use ssh to bypass the sudo "require tty" setting ssh -o "StrictHostKeyChecking no" -t -t ec2-user@localhost <<- EOF sudo su -; } # The yield to be run as root script << yield script << %{ # exit twice, once for su and once for ssh exit; exit; EOF } end
install_gems_script(&blk)
click to toggle source
# File lib/pipely/deploy/bootstrap_context.rb, line 33 def install_gems_script(&blk) @parent.install_gems_script(:awscli, &blk) end