Module: AnotherBrick::Server

Extended by:
Server
Included in:
Server
Defined in:
lib/another_brick/server.rb

Instance Method Summary collapse

Instance Method Details

#deploy(tag) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/another_brick/server.rb', line 5

def deploy(tag)
  Net::SSH.start AnotherBrick.deploy_server, AnotherBrick.deploy_user do |ssh|
    AnotherBrick.max_tries.times do
      exec(ssh, "apt-get update")
      cache_show = exec(ssh, "apt-cache show #{AnotherBrick.package_name}")
      version = tag.split('_')[1]

      unless cache_show =~ /#{AnotherBrick.package_name}_#{version}_(.*)\.deb/
        sleep 2
        next
      end

      exec(ssh, "apt-get install --force-yes -y #{AnotherBrick.package_name}")
      break
    end
  end
end

#exec(ssh, command) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/another_brick/server.rb', line 23

def exec(ssh, command)
  ssh.exec!(command).tap do |result|
    return result unless AnotherBrick.verbose?
    puts command
    puts result
  end
end