escualo 1.0.3 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/escualo +5 -7
- data/lib/command.rb +6 -7
- data/lib/commands/artifact.rb +47 -79
- data/lib/commands/bootstrap.rb +30 -25
- data/lib/commands/deploy.rb +8 -6
- data/lib/commands/env.rb +12 -9
- data/lib/commands/globals.rb +7 -36
- data/lib/commands/plugin.rb +9 -19
- data/lib/commands/rake.rb +3 -5
- data/lib/commands/remote.rb +6 -5
- data/lib/commands/script.rb +6 -25
- data/lib/commands/upload.rb +2 -2
- data/lib/escualo/apt_get.rb +10 -0
- data/lib/escualo/artifact.rb +40 -43
- data/lib/escualo/base.rb +36 -15
- data/lib/escualo/env.rb +22 -32
- data/lib/escualo/gems.rb +4 -4
- data/lib/escualo/plugin/docker.rb +4 -4
- data/lib/escualo/plugin/haskell.rb +4 -4
- data/lib/escualo/plugin/mongo.rb +6 -10
- data/lib/escualo/plugin/monit.rb +16 -17
- data/lib/escualo/plugin/nginx.rb +7 -10
- data/lib/escualo/plugin/node.rb +6 -8
- data/lib/escualo/plugin/postgres.rb +26 -0
- data/lib/escualo/plugin/rabbit.rb +9 -14
- data/lib/escualo/plugin.rb +1 -6
- data/lib/escualo/remote.rb +18 -20
- data/lib/escualo/ruby.rb +17 -0
- data/lib/escualo/script.rb +7 -61
- data/lib/escualo/session/docker_session.rb +56 -0
- data/lib/escualo/session/local_session.rb +23 -0
- data/lib/escualo/session/remote_session.rb +42 -0
- data/lib/escualo/session.rb +83 -0
- data/lib/escualo/version.rb +2 -2
- data/lib/escualo.rb +13 -1
- data/lib/ssh.rb +26 -4
- data/lib/templates/codechange.sh.erb +1 -1
- data/lib/templates/init.sh.erb +7 -0
- data/lib/templates/post-receive.sh.erb +8 -2
- metadata +9 -9
- data/lib/commands/base.rb +0 -8
- data/lib/escualo/bootstrap.rb +0 -37
- data/lib/escualo/plugin/postgre.rb +0 -23
- data/lib/ssh/local_session.rb +0 -44
- data/lib/ssh/perform.rb +0 -9
- data/lib/ssh/session.rb +0 -61
- data/lib/ssh/upload.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a1b1332770052855fe4cf7dd3fc315d59c7013d
|
4
|
+
data.tar.gz: c1ed05104e4191224af4cba5ebd1471d8be6f188
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99fb17f7ccea1a403c6f4622db1ff626bb5edb416ddd2a99691323c15440df7957f616c303a1d46ef78621595bccdf119a8a4af6d8a97f63d0002139cd87633c
|
7
|
+
data.tar.gz: a65eee75b9d738447f68c06decf20c465c4fc7480a1830a731262d1d90356364b1ce98fffbfe2cfb2a61c7819a59261c3f244f7c033a2beba8960e4f54558582
|
data/bin/escualo
CHANGED
@@ -10,23 +10,21 @@ program :description, 'escualo provisioning tool implementation for ruby'
|
|
10
10
|
|
11
11
|
require_relative '../lib/command'
|
12
12
|
|
13
|
-
def step(name, &block)
|
14
|
-
say name
|
13
|
+
def step(name, options=struct, &block)
|
14
|
+
say name unless options.dockerized
|
15
15
|
block.call
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
19
|
-
if !options.force &&
|
18
|
+
def exit_if(done_message, options)
|
19
|
+
if !options.force && !options.dockerized && yield
|
20
20
|
say "Nothing to do. #{done_message}"
|
21
21
|
say 'Use --force to proceed it anyway'
|
22
|
-
|
23
|
-
yield
|
22
|
+
exit
|
24
23
|
end
|
25
24
|
end
|
26
25
|
|
27
26
|
require_relative '../lib/commands/globals'
|
28
27
|
|
29
|
-
require_relative '../lib/commands/base'
|
30
28
|
require_relative '../lib/commands/bootstrap'
|
31
29
|
require_relative '../lib/commands/deploy'
|
32
30
|
require_relative '../lib/commands/script'
|
data/lib/command.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
class Commander::Command
|
2
|
-
def
|
2
|
+
def session_action(force_local=false, &block)
|
3
3
|
action do |args, options|
|
4
|
-
|
5
|
-
say "Connecting to remote host #{$hostname}... " if options.verbose
|
6
|
-
else
|
7
|
-
say 'Running commands locally... ' if options.verbose
|
8
|
-
end
|
9
|
-
Net::SSH.with_session(ssh_session_options) { |ssh| block.call(args, options, ssh) }
|
4
|
+
Escualo::Session.within(options, force_local) { |session| block.call(args, options, session) }
|
10
5
|
end
|
11
6
|
end
|
7
|
+
|
8
|
+
def local_session_action(&block)
|
9
|
+
session_action true, &block
|
10
|
+
end
|
12
11
|
end
|
data/lib/commands/artifact.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
command 'artifact list' do |c|
|
2
2
|
c.syntax = 'escualo artifact list'
|
3
3
|
c.description = 'Lists artifacts on host'
|
4
|
-
c.
|
5
|
-
Escualo::Artifact.list(
|
4
|
+
c.session_action do |args, options, session|
|
5
|
+
Escualo::Artifact.list(session).each do |artifact|
|
6
6
|
say artifact
|
7
7
|
end
|
8
8
|
end
|
@@ -11,65 +11,43 @@ end
|
|
11
11
|
command 'artifact destroy' do |c|
|
12
12
|
c.syntax = 'escualo artifact destroy <NAME>'
|
13
13
|
c.description = 'Destroys an artifact on host'
|
14
|
-
c.
|
15
|
-
|
16
|
-
|
17
|
-
Escualo::Artifact.destroy(ssh, name)
|
18
|
-
|
19
|
-
if !Escualo::Artifact.present? ssh, name
|
20
|
-
say "#{name} destroyed successfully"
|
21
|
-
else
|
22
|
-
abort "Could not destroy artifact #{name}"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def check_created(kind, name)
|
28
|
-
if Escualo::Artifact.present?(ssh, name)
|
29
|
-
say "#{kind.titleize} #{name} created successfully"
|
30
|
-
say "Now you can deploy this #{kind}"
|
31
|
-
else
|
32
|
-
abort "Failed to create artifact #{name}"
|
14
|
+
c.session_action do |args, options, session|
|
15
|
+
Escualo::Artifact.destroy(session, args.first)
|
33
16
|
end
|
34
17
|
end
|
35
18
|
|
36
19
|
command 'artifact create service' do |c|
|
37
20
|
c.syntax = 'escualo artifact create service <NAME> <PORT>'
|
38
21
|
c.description = 'Setup a micro-service deployment'
|
39
|
-
c.option '-f', '--force', TrueClass, 'Force creation even if already done'
|
40
22
|
|
41
|
-
c.
|
23
|
+
c.session_action do |args, options, session|
|
42
24
|
name = args.first
|
43
25
|
port = args.second
|
44
26
|
|
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
|
-
Escualo::Artifact.create_push_infra ssh, name: name, service: true
|
70
|
-
end
|
71
|
-
|
72
|
-
check_created 'service', name
|
27
|
+
exit_if("Service #{name} already created", options) { Escualo::Artifact.present?(session, name) }
|
28
|
+
|
29
|
+
launch_command = "exec bundle exec rackup -o 0.0.0.0 -p #{port} > rack.log"
|
30
|
+
install_command='bundle install --without development test'
|
31
|
+
|
32
|
+
step 'Creating init scripts...', options do
|
33
|
+
Escualo::Artifact.create_scripts_dir session, name
|
34
|
+
Escualo::Artifact.create_init_script session,
|
35
|
+
name: name,
|
36
|
+
service: true,
|
37
|
+
install_command: install_command
|
38
|
+
Escualo::Artifact.create_codechange_script session, name
|
39
|
+
end
|
40
|
+
|
41
|
+
step 'Configuring upstart...', options do
|
42
|
+
Escualo::Artifact.configure_upstart session, name: name, launch_command: launch_command
|
43
|
+
end
|
44
|
+
|
45
|
+
step 'Configuring monit...', options do
|
46
|
+
Escualo::Artifact.configure_monit session, name: name, port: port
|
47
|
+
end
|
48
|
+
|
49
|
+
step 'Creating push infrastructure', options do
|
50
|
+
Escualo::Artifact.create_push_infra session, name: name, service: true
|
73
51
|
end
|
74
52
|
end
|
75
53
|
end
|
@@ -77,23 +55,18 @@ end
|
|
77
55
|
command 'artifact create site' do |c|
|
78
56
|
c.syntax = 'escualo artifact create site <NAME>'
|
79
57
|
c.description = 'Setup an static site deployment'
|
80
|
-
c.option '-f', '--force', TrueClass, 'Force creation even if already done'
|
81
58
|
|
82
|
-
c.
|
59
|
+
c.session_action do |args, options, session|
|
83
60
|
name = args.first
|
61
|
+
exit_if("Site #{name} already created", options) { Escualo::Artifact.present?(session, name) }
|
84
62
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
step 'Creating push infrastructure' do
|
94
|
-
Escualo::Artifact.create_push_infra ssh, name: name, static: true
|
95
|
-
end
|
96
|
-
check_created 'site', name
|
63
|
+
step 'Creating init scripts...', options do
|
64
|
+
Escualo::Artifact.create_scripts_dir session, name
|
65
|
+
Escualo::Artifact.create_init_script session, name: name, static: true
|
66
|
+
end
|
67
|
+
|
68
|
+
step 'Creating push infrastructure', options do
|
69
|
+
Escualo::Artifact.create_push_infra session, name: name, static: true
|
97
70
|
end
|
98
71
|
end
|
99
72
|
end
|
@@ -101,23 +74,18 @@ end
|
|
101
74
|
command 'artifact create executable' do |c|
|
102
75
|
c.syntax = 'escualo artifact create executable <NAME>'
|
103
76
|
c.description = 'Setup an executable command deployment'
|
104
|
-
c.option '-f', '--force', TrueClass, 'Force creation even if already done'
|
105
77
|
|
106
|
-
c.
|
78
|
+
c.session_action do |args, options, session|
|
107
79
|
name = args.first
|
108
80
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
step 'Creating push infrastructure' do
|
118
|
-
Escualo::Artifact.create_push_infra ssh, name: name, executable: true
|
119
|
-
end
|
120
|
-
check_created 'executable', name
|
81
|
+
exit_if("Executable #{name} already created", options) { Escualo::Artifact.present?(session, name) }
|
82
|
+
step 'Creating init scripts...', options do
|
83
|
+
Escualo::Artifact.create_scripts_dir session, name
|
84
|
+
Escualo::Artifact.create_init_script session, name: name, executable: true
|
85
|
+
end
|
86
|
+
|
87
|
+
step 'Creating push infrastructure', options do
|
88
|
+
Escualo::Artifact.create_push_infra session, name: name, executable: true
|
121
89
|
end
|
122
90
|
end
|
123
91
|
end
|
data/lib/commands/bootstrap.rb
CHANGED
@@ -4,40 +4,45 @@ command 'bootstrap' do |c|
|
|
4
4
|
c.option '--swap', TrueClass, 'Setup swap?'
|
5
5
|
c.option '--env ENVIRONMENT', String, 'Environment. Valid options are development and production. default is production'
|
6
6
|
c.option '--with-rbenv', TrueClass, 'Use rbenv instead of native ruby installation'
|
7
|
-
c.option '-f', '--force', TrueClass, 'Force bootstrap even if already done?'
|
8
7
|
|
9
|
-
c.
|
8
|
+
c.session_action do |_args, options, session|
|
10
9
|
options.default env: 'production'
|
11
10
|
|
12
|
-
|
11
|
+
exit_if('This host has already been bootstrapped', options) do
|
12
|
+
Escualo::Env.present?(session, :ESCUALO_BASE_VERSION) && Escualo::Gems.installed?(session)
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
step 'Configuring variables...', options do
|
16
|
+
Escualo::Env.setup session
|
17
|
+
Escualo::Env.set_builtins session, options
|
18
|
+
end
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
Escualo::Env.set_builtins ssh, options
|
22
|
-
end
|
20
|
+
step 'Configuring locales...', options do
|
21
|
+
Escualo::Base.configure_locales session
|
22
|
+
end
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
step 'Installing base software', options do
|
25
|
+
Escualo::Base.install session
|
26
|
+
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
step 'Adding package repositories', options do
|
29
|
+
Escualo::Base.add_repositories session
|
30
|
+
end
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
step 'Enabling swap...', options do
|
33
|
+
Escualo::Base.enable_swap session
|
34
|
+
end if options.swap
|
35
|
+
|
36
|
+
step 'Installing Ruby...', options do
|
37
|
+
Escualo::Ruby.install session, options
|
38
|
+
end
|
39
|
+
|
40
|
+
step 'Installing gems...', options do
|
41
|
+
Escualo::Gems.install session
|
42
|
+
end
|
35
43
|
|
36
|
-
|
37
|
-
|
38
|
-
else
|
39
|
-
abort 'bootstrapping failed'
|
40
|
-
end
|
44
|
+
step 'Setup artifact directories...', options do
|
45
|
+
Escualo::Artifact.setup session
|
41
46
|
end
|
42
47
|
end
|
43
48
|
end
|
data/lib/commands/deploy.rb
CHANGED
@@ -2,15 +2,17 @@ command 'deploy' do |c|
|
|
2
2
|
c.syntax = 'escualo deploy <name> <repo>'
|
3
3
|
c.description = 'Deploys repository to the given executable, service or site'
|
4
4
|
c.option '--tag GIT_TAG', String, 'Github tag to deploy'
|
5
|
-
c.
|
5
|
+
c.local_session_action do |args, options, session|
|
6
|
+
session_options = Escualo::Session.parse_session_options(options)
|
7
|
+
|
6
8
|
Dir.mktmpdir do |dir|
|
7
|
-
step 'Cloning repository...' do
|
8
|
-
Escualo::Remote.clone dir, args.second, options
|
9
|
-
Escualo::Remote.attach dir, args.first
|
9
|
+
step 'Cloning repository...', options do
|
10
|
+
Escualo::Remote.clone session, dir, args.second, options
|
11
|
+
Escualo::Remote.attach session, dir, args.first, session_options
|
10
12
|
end
|
11
13
|
|
12
|
-
step 'Pushing to remote...' do
|
13
|
-
Escualo::Remote.push dir
|
14
|
+
step 'Pushing to remote...', options do
|
15
|
+
Escualo::Remote.push session, dir
|
14
16
|
end
|
15
17
|
end
|
16
18
|
end
|
data/lib/commands/env.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
command 'env list' do |c|
|
2
2
|
c.syntax = 'escualo env list'
|
3
3
|
c.description = 'List escualo variables on host'
|
4
|
-
c.
|
5
|
-
say Escualo::Env.list
|
4
|
+
c.session_action do |_args, _options, session|
|
5
|
+
say Escualo::Env.list session
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
9
|
-
|
10
9
|
def parse_args_variables(args)
|
11
10
|
args.map { |it| it.split('=') }.to_h
|
12
11
|
end
|
@@ -14,23 +13,27 @@ end
|
|
14
13
|
command 'env set' do |c|
|
15
14
|
c.syntax = 'escualo env set <NAME>=<VALUE> [<NAME>=<VALUE>,...<NAME>=<VALUE>]'
|
16
15
|
c.description = 'Sets one or more escualo variables on host'
|
17
|
-
c.
|
18
|
-
Escualo::Env.set
|
16
|
+
c.session_action do |args, _options, session|
|
17
|
+
Escualo::Env.set session, parse_args_variables(args)
|
19
18
|
end
|
20
19
|
end
|
21
20
|
|
22
21
|
command 'env unset' do |c|
|
23
22
|
c.syntax = 'escualo env unset <NAME> [<NAME>,...<NAME>]'
|
24
23
|
c.description = 'Unset escualo variables on host'
|
25
|
-
c.
|
26
|
-
Escualo::Env.unset
|
24
|
+
c.session_action do |args, _options, session|
|
25
|
+
Escualo::Env.unset session, args
|
27
26
|
end
|
28
27
|
end
|
29
28
|
|
30
29
|
command 'env clean' do |c|
|
31
30
|
c.syntax = 'escualo env clean'
|
31
|
+
c.option '--env ENVIRONMENT', String, 'Environment. Valid options are development and production. default is production'
|
32
|
+
|
32
33
|
c.description = 'Unset all escualo variables on host'
|
33
|
-
c.
|
34
|
-
|
34
|
+
c.session_action do |_args, options, session|
|
35
|
+
options.default env: 'production'
|
36
|
+
|
37
|
+
Escualo::Env.clean session, options
|
35
38
|
end
|
36
39
|
end
|
data/lib/commands/globals.rb
CHANGED
@@ -1,41 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
$ssh_options = {}
|
4
|
-
$ssh_remote = false
|
1
|
+
global_option '-h', '--hostname HOSTNAME', String, 'The host to connect. Defaults to "localhost"'
|
2
|
+
global_option '-u', '--username USERNAME', String, 'The username to connect. Defaults to "root"'
|
5
3
|
|
6
|
-
global_option '-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
4
|
+
global_option '-i', '--ssh-key PRIVATE_KEY', String, 'An optional private key'
|
5
|
+
global_option '--ssh-port PORT', String, 'The ssh port to connect. Defaults to 22'
|
6
|
+
global_option '--ssh-password PASSWORD', String, 'An optional remote password'
|
10
7
|
|
11
|
-
global_option '
|
12
|
-
$username = username
|
13
|
-
$ssh_remote = true
|
14
|
-
end
|
15
|
-
|
16
|
-
global_option '--password PASSWORD', String, 'An optional remote password' do |password|
|
17
|
-
$password = password
|
18
|
-
$ssh_options[:password] = password
|
19
|
-
$ssh_remote = true
|
20
|
-
end
|
21
|
-
|
22
|
-
global_option '-i', '--ssh-key PRIVATE_KEY', String, 'An optional private key' do |private_key|
|
23
|
-
$ssh_key = private_key
|
24
|
-
$ssh_options[:keys] = [private_key]
|
25
|
-
$ssh_remote = true
|
26
|
-
end
|
27
|
-
|
28
|
-
global_option '--ssh-port PORT', String, 'The ssh port to connect. Defaults to 22' do |port|
|
29
|
-
$ssh_port = port
|
30
|
-
$ssh_options[:port] = port
|
31
|
-
$ssh_remote = true
|
32
|
-
end
|
8
|
+
global_option '--dockerized', TrueClass, 'Generate a docker script instead of running the commands'
|
33
9
|
|
34
10
|
global_option '--verbose', TrueClass, 'Dumps extra output'
|
35
11
|
|
36
|
-
|
37
|
-
$ssh_options.merge(
|
38
|
-
username: $username,
|
39
|
-
hostname: $hostname,
|
40
|
-
local: !$ssh_remote).compact
|
41
|
-
end
|
12
|
+
global_option '-f', '--force', TrueClass, 'Force command run'
|
data/lib/commands/plugin.rb
CHANGED
@@ -6,31 +6,23 @@ command 'plugin install' do |c|
|
|
6
6
|
c.option '--rabbit-admin-password PASSWORD', String, 'rabbitmq admin password, only for rabbit plugin'
|
7
7
|
|
8
8
|
c.option '--pg-version VERSION', String, 'PostgreSQL major and minor version. Default is 9.3, only for postgre plugin'
|
9
|
+
c.option '--pg-username USERNAME', String, 'PostgreSQL username'
|
10
|
+
c.option '--pg-password PASSWORD', String, 'PostgreSQL password'
|
9
11
|
|
10
12
|
c.option '--monit-version VERSION', String, 'Monit version. Default is 5.16'
|
11
13
|
c.option '--monit-password PASSWORD', String, 'Monit password. Required with monit plugin'
|
12
14
|
|
13
|
-
c.
|
14
|
-
c.ssh_action do |args, options, ssh|
|
15
|
+
c.session_action do |args, options, session|
|
15
16
|
options.default pg_version: '9.3',
|
16
17
|
monit_version: '5.16'
|
17
18
|
|
18
19
|
plugin = args.first
|
19
|
-
say "Installing #{plugin}"
|
20
|
-
|
21
20
|
installer = Escualo::Plugin.load plugin
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
step "Installing plugin #{plugin}" do
|
28
|
-
if Escualo::Plugin.run_and_check installer, ssh, options
|
29
|
-
say 'Installed successfully!'
|
30
|
-
else
|
31
|
-
abort 'Installation of plugin failed'
|
32
|
-
end
|
33
|
-
end
|
22
|
+
exit_if("Plugin #{plugin} is already installed", options) { installer.installed?(session, options) }
|
23
|
+
|
24
|
+
step "Installing plugin #{plugin}", options do
|
25
|
+
installer.run session, options
|
34
26
|
end
|
35
27
|
end
|
36
28
|
end
|
@@ -39,11 +31,9 @@ command 'plugin list' do |c|
|
|
39
31
|
c.syntax = 'escualo plugin list'
|
40
32
|
c.description = 'List installed plugins on host'
|
41
33
|
|
42
|
-
c.
|
34
|
+
c.session_action do |_args, _options, session|
|
43
35
|
Escualo::Plugin::PLUGINS.each do |plugin|
|
44
|
-
if Escualo::Plugin.load(plugin).
|
45
|
-
say plugin
|
46
|
-
end
|
36
|
+
say plugin if Escualo::Plugin.load(plugin).installed? session
|
47
37
|
end
|
48
38
|
end
|
49
39
|
end
|
data/lib/commands/rake.rb
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
command 'rake' do |c|
|
2
2
|
c.syntax = 'escualo rake <SERVICE_NAME> <TASK>'
|
3
3
|
c.description = 'Run rake task on host'
|
4
|
-
c.
|
4
|
+
c.session_action do |args, _options, session|
|
5
5
|
name = args.first
|
6
6
|
task = args.second
|
7
|
-
|
8
|
-
|
9
|
-
rake #{task}
|
10
|
-
}, options
|
7
|
+
|
8
|
+
session.tell! "cd /var/www/#{name} && rake #{task}"
|
11
9
|
end
|
12
10
|
end
|
13
11
|
|
data/lib/commands/remote.rb
CHANGED
@@ -3,10 +3,11 @@ command 'remote attach' do |c|
|
|
3
3
|
c.description = "Adds the given artifact to current's repository"
|
4
4
|
c.option '--repo-path PATH', String, 'Sets the git dir'
|
5
5
|
|
6
|
-
c.
|
6
|
+
c.local_session_action do |args, options, session|
|
7
7
|
options.default repo_path: Dir.pwd
|
8
|
+
session_options = Escualo::Session.parse_session_options options
|
8
9
|
|
9
|
-
Escualo::Remote.attach options.repo_path, args.first
|
10
|
+
Escualo::Remote.attach session, options.repo_path, args.first, session_options
|
10
11
|
end
|
11
12
|
end
|
12
13
|
|
@@ -15,10 +16,10 @@ command 'remote show' do |c|
|
|
15
16
|
c.description = "Show attached artifacts to current's repository"
|
16
17
|
c.option '--repo-path PATH', String, 'Sets the git dir'
|
17
18
|
|
18
|
-
c.
|
19
|
+
c.local_session_action do |_args, options, session|
|
19
20
|
options.default repo_path: Dir.pwd
|
20
21
|
|
21
|
-
Escualo::Remote.remotes(options.repo_path).each { |it| say it }
|
22
|
+
Escualo::Remote.remotes(session, options.repo_path).each { |it| say it }
|
22
23
|
end
|
23
24
|
end
|
24
25
|
|
@@ -26,7 +27,7 @@ command 'remote push' do |c|
|
|
26
27
|
c.syntax = 'escualo remote push'
|
27
28
|
c.description = 'Pushes artifact at current repository'
|
28
29
|
c.action do |_args, _options|
|
29
|
-
Escualo::Remote.push Dir.pwd
|
30
|
+
Escualo::Remote.push session, Dir.pwd
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
data/lib/commands/script.rb
CHANGED
@@ -2,38 +2,19 @@ command 'script' do |c|
|
|
2
2
|
c.syntax = 'escualo script <FILE>'
|
3
3
|
c.description = 'Runs a escualo configuration'
|
4
4
|
c.option '--dockerized', TrueClass, 'Create a Dockerfile instead of running commands'
|
5
|
+
c.option '--write-dockerfile', TrueClass, 'Write a complete Dockerfile instead of writing to stdout. Default is false'
|
6
|
+
c.option '--dockerfile PATH', String, 'Destination Dockerfile. Default is `Dockerfile`'
|
5
7
|
c.option '--development', TrueClass, 'Use local escualo gemspec instead of fetching from internet'
|
6
8
|
c.option '--base-image BASE_IMAGE', String, 'Default base image. Only for dockerized runs'
|
7
9
|
|
8
10
|
c.action do |args, options|
|
9
|
-
options.default base_image: 'ubuntu'
|
10
|
-
|
11
|
-
if options.dockerized
|
12
|
-
mode = Escualo::Script::Dockerized.new
|
13
|
-
else
|
14
|
-
mode = Escualo::Script::Standard.new
|
15
|
-
end
|
16
|
-
|
17
|
-
mode.start! options
|
18
|
-
|
11
|
+
options.default base_image: 'ubuntu',
|
12
|
+
dockerfile: 'Dockerfile'
|
19
13
|
file = YAML.load_file args.first
|
20
|
-
|
21
|
-
local_ssh = Net::SSH::Connection::LocalSession.new
|
22
14
|
delegated_options = Escualo::Script.delegated_options options
|
23
15
|
|
24
|
-
|
25
|
-
|
16
|
+
Escualo::Session.within(options, true) do |session|
|
17
|
+
Escualo::Script.run!(session, $PROGRAM_NAME, file, delegated_options)
|
26
18
|
end
|
27
|
-
step 'Running remote commands...' do
|
28
|
-
Net::SSH.with_session(ssh_session_options) do |ssh|
|
29
|
-
mode.run_commands_for! file['remote'], ssh, options
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
step 'Running deploy commands...' do
|
34
|
-
mode.run_commands_for! file['deploy'], delegated_options, local_ssh, options
|
35
|
-
end
|
36
|
-
|
37
|
-
mode.finish!
|
38
19
|
end
|
39
20
|
end
|
data/lib/commands/upload.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
command 'upload' do |c|
|
2
2
|
c.syntax = 'escualo upload <FILE> <DESTINATION>'
|
3
3
|
c.description = 'Upload file to host'
|
4
|
-
c.
|
5
|
-
|
4
|
+
c.session_action do |args, _options, session|
|
5
|
+
session.upload! args.first, args.second
|
6
6
|
end
|
7
7
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Escualo::AptGet
|
2
|
+
def self.install(session, packages_string, options={})
|
3
|
+
session.tell_all! update_command(options),
|
4
|
+
"apt-get install -y --force-yes #{packages_string}"
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.update_command(options)
|
8
|
+
'apt-get update' if options[:update]
|
9
|
+
end
|
10
|
+
end
|