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



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
78
79
80
81
82
# File 'lib/danarchy_deploy.rb', line 44

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

  @working_dir = File.dirname(options[:deploy_file]) + '/'
  connector = { hostname: deployment[:hostname],
                ipv4:     deployment[:ipv4],
                ssh_user: deployment[:ssh_user],
                ssh_key:  deployment[:ssh_key] }

  pretend = options[:pretend] ; options[:pretend] = false
  remote_mkdir(connector, options)
  # asdf_install(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_templates(connector, options)
  push_deployment(connector, options)

  options[:pretend] = pretend
  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!"
  options[:deploy_file].end_with?('.json') ?
    JSON.parse(File.read(options[:deploy_file]), symbolize_names: true) :
    YAML.load_file(options[:deploy_file]) if options[:deploy_file].end_with?('.yaml')
end