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
83
84
85
86
87
88
|
# File 'lib/confctl/cli/cluster.rb', line 45
def deploy
machines = select_machines(args[0]).managed
action = args[1] || 'switch'
raise GLI::BadCommandLine, "invalid action '#{action}'" unless %w[boot switch test dry-activate].include?(action)
if opts[:reboot]
raise GLI::BadCommandLine, '--reboot can be used only with switch-action boot' if action != 'boot'
parse_wait_online
end
raise 'No machines to deploy' if machines.empty?
ask_confirmation! do
puts 'The following machines will be deployed:'
list_machines(machines)
puts
puts "Generation: #{opts[:generation] || 'new build'}"
puts "Target action: #{action}#{opts[:reboot] ? ' + reboot' : ''}"
end
ConfCtl::Hook.call(:cluster_deploy, kwargs: {
machines:,
generation: opts[:generation],
action: opts[:action],
opts:
})
host_generations =
if opts[:generation]
find_generations(machines, opts[:generation])
else
do_build(machines)
end
nix = ConfCtl::Nix.new(show_trace: opts['show-trace'])
if opts['one-by-one']
deploy_one_by_one(machines, host_generations, nix, action)
else
deploy_in_bulk(machines, host_generations, nix, action)
end
end
|