Class: DanarchyDeploy::RemoteDeploy

Inherits:
Object
  • Object
show all
Defined in:
lib/danarchy_deploy.rb

Class Method Summary collapse

Class Method Details

.new(deployment, options) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/danarchy_deploy.rb', line 43

def self.new(deployment, options)
  puts "\n" + self.name

  options[:working_dir] = options[:deploy_dir] + '/' + deployment[:hostname]
  connector = { hostname: deployment[:hostname],
                ipv4:     deployment[:ipv4],
                ssh_user: deployment[:ssh_user],
                ssh_key:  deployment[:ssh_key] }

  remote_mkdir(connector, options)

  if options[:dev_gem]
    puts "\nDev Gem mode: Building and pushing gem..."
    gem = dev_gem_build(options)
    dev_gem_install(connector, gem, options)
  else
    gem_install(connector, options)
  end

  gem_clean(connector, options)
  gem_binary = _locate_gem_binary(connector, options) # this should run before any install; check version too
  push_temmplates(connector, options)
  push_deployment(connector, options)
  deploy_result = remote_LocalDeploy(connector, gem_binary, options)

  abort("\n ! Deployment failed to complete!") if !deploy_result

  pull_deployment(connector, options) if !options[:pretend]
  # remote_cleanup(connector, options) if !options[:pretend]

  puts "\nRemote deployment complete!"
  deployment = JSON.parse(File.read(options[:deploy_file]), symbolize_names: true) if options[:deploy_file].end_with?('.json')
  deployment = YAML.load_file(options[:deploy_file]) if options[:deploy_file].end_with?('.yaml')
  deployment
end