escualo 1.0.3 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/bin/escualo +5 -7
  3. data/lib/command.rb +6 -7
  4. data/lib/commands/artifact.rb +47 -79
  5. data/lib/commands/bootstrap.rb +30 -25
  6. data/lib/commands/deploy.rb +8 -6
  7. data/lib/commands/env.rb +12 -9
  8. data/lib/commands/globals.rb +7 -36
  9. data/lib/commands/plugin.rb +9 -19
  10. data/lib/commands/rake.rb +3 -5
  11. data/lib/commands/remote.rb +6 -5
  12. data/lib/commands/script.rb +6 -25
  13. data/lib/commands/upload.rb +2 -2
  14. data/lib/escualo/apt_get.rb +10 -0
  15. data/lib/escualo/artifact.rb +40 -43
  16. data/lib/escualo/base.rb +36 -15
  17. data/lib/escualo/env.rb +22 -32
  18. data/lib/escualo/gems.rb +4 -4
  19. data/lib/escualo/plugin/docker.rb +4 -4
  20. data/lib/escualo/plugin/haskell.rb +4 -4
  21. data/lib/escualo/plugin/mongo.rb +6 -10
  22. data/lib/escualo/plugin/monit.rb +16 -17
  23. data/lib/escualo/plugin/nginx.rb +7 -10
  24. data/lib/escualo/plugin/node.rb +6 -8
  25. data/lib/escualo/plugin/postgres.rb +26 -0
  26. data/lib/escualo/plugin/rabbit.rb +9 -14
  27. data/lib/escualo/plugin.rb +1 -6
  28. data/lib/escualo/remote.rb +18 -20
  29. data/lib/escualo/ruby.rb +17 -0
  30. data/lib/escualo/script.rb +7 -61
  31. data/lib/escualo/session/docker_session.rb +56 -0
  32. data/lib/escualo/session/local_session.rb +23 -0
  33. data/lib/escualo/session/remote_session.rb +42 -0
  34. data/lib/escualo/session.rb +83 -0
  35. data/lib/escualo/version.rb +2 -2
  36. data/lib/escualo.rb +13 -1
  37. data/lib/ssh.rb +26 -4
  38. data/lib/templates/codechange.sh.erb +1 -1
  39. data/lib/templates/init.sh.erb +7 -0
  40. data/lib/templates/post-receive.sh.erb +8 -2
  41. metadata +9 -9
  42. data/lib/commands/base.rb +0 -8
  43. data/lib/escualo/bootstrap.rb +0 -37
  44. data/lib/escualo/plugin/postgre.rb +0 -23
  45. data/lib/ssh/local_session.rb +0 -44
  46. data/lib/ssh/perform.rb +0 -9
  47. data/lib/ssh/session.rb +0 -61
  48. data/lib/ssh/upload.rb +0 -9
@@ -1,72 +1,69 @@
1
1
  module Escualo
2
2
  module Artifact
3
- def self.setup(ssh)
4
- ssh.exec! %q{
5
- mkdir -p /var/repo/ && \
6
- mkdir -p /var/scripts/
7
- }
3
+ def self.setup(session)
4
+ session.tell_all! 'mkdir -p /var/repo/',
5
+ 'mkdir -p /var/scripts/'
8
6
  end
9
7
 
10
- def self.destroy(ssh, name)
8
+ def self.destroy(session, name)
11
9
  raise 'name must not be blank' if name.blank?
12
10
  raise 'name must not contains wildcards' if name.include?('*')
13
11
 
14
- ssh.exec! "rm -rf /var/scripts/#{name}"
15
- ssh.exec! "rm -rf /var/repo/#{name}.git"
16
- ssh.exec! "rm -f /etc/monit/conf.d/escualo-#{name}"
17
- ssh.exec! "rm -f /etc/init/#{name}.conf"
12
+ session.tell_all! "rm -rf /var/scripts/#{name}",
13
+ "rm -rf /var/repo/#{name}.git",
14
+ "rm -f /etc/monit/conf.d/escualo-#{name}",
15
+ "rm -f /etc/init/#{name}.conf",
16
+ "test ! -e /var/repo/#{name}.git"
18
17
  end
19
18
 
20
- def self.present?(ssh, name)
21
- list(ssh).include? name
19
+ def self.present?(session, name)
20
+ list(session).include? name rescue false
22
21
  end
23
22
 
24
- def self.create_scripts_dir(ssh, name)
25
- ssh.exec! "mkdir -p /var/scripts/#{name}"
23
+ def self.create_scripts_dir(session, name)
24
+ session.tell! "mkdir -p /var/scripts/#{name}"
26
25
  end
27
26
 
28
- def self.create_init_script(ssh, options)
29
- ssh.upload_template! "/var/scripts/#{options[:name]}/init",
30
- 'init.sh',
31
- options
32
- ssh.exec! "chmod +x /var/scripts/#{options[:name]}/init"
27
+ def self.create_init_script(session, options)
28
+ session.upload_template! "/var/scripts/#{options[:name]}/init",
29
+ 'init.sh',
30
+ options
31
+ session.tell! "chmod +x /var/scripts/#{options[:name]}/init"
33
32
  end
34
33
 
35
- def self.list(ssh)
36
- ssh.exec!('ls /var/repo/').captures(/(.*)\.git/).map { $1 }
34
+ def self.list(session)
35
+ session.ask('ls /var/repo/').captures(/(.*)\.git/).map { $1 }
37
36
  end
38
37
 
39
- def self.create_push_infra(ssh, options)
38
+ def self.create_push_infra(session, options)
40
39
  name = options[:name]
41
- ssh.exec! %Q{\
42
- cd /var && \
43
- mkdir -p www && \
44
- mkdir -p repo && \
45
- cd repo && \
46
- rm -rf #{name}.git && \
47
- mkdir #{name}.git && \
48
- cd #{name}.git && \
49
- git init --bare
50
- }
40
+ session.tell_all! 'cd /var',
41
+ 'mkdir -p www',
42
+ 'mkdir -p repo',
43
+ 'cd repo',
44
+ "rm -rf #{name}.git",
45
+ "mkdir #{name}.git",
46
+ "cd #{name}.git",
47
+ 'git init --bare'
51
48
  hook_file = "/var/repo/#{name}.git/hooks/post-receive"
52
- ssh.upload_template! hook_file, 'post-receive.sh', options
53
- ssh.exec! "chmod +x #{hook_file}"
49
+ session.upload_template! hook_file, 'post-receive.sh', options
50
+ session.tell! "chmod +x #{hook_file}"
54
51
  end
55
52
 
56
- def self.configure_monit(ssh, options)
53
+ def self.configure_monit(session, options)
57
54
  name = options[:name]
58
- ssh.exec! 'mkdir -p /etc/monit/conf.d/'
59
- ssh.upload_template! "/etc/monit/conf.d/escualo-#{name}", 'monit.conf', options
60
- ssh.exec! 'monit reload'
55
+ session.tell! 'mkdir -p /etc/monit/conf.d/'
56
+ session.upload_template! "/etc/monit/conf.d/escualo-#{name}", 'monit.conf', options
57
+ session.tell! 'monit reload'
61
58
  end
62
59
 
63
- def self.create_codechange_script(ssh, name)
64
- ssh.upload_template! "/var/scripts/#{name}/codechange", 'codechange.sh', name: name
65
- ssh.exec! "chmod +x /var/scripts/#{name}/codechange"
60
+ def self.create_codechange_script(session, name)
61
+ session.upload_template! "/var/scripts/#{name}/codechange", 'codechange.sh', name: name
62
+ session.tell! "chmod +x /var/scripts/#{name}/codechange"
66
63
  end
67
64
 
68
- def self.configure_upstart(ssh, options)
69
- ssh.upload_template! "/etc/init/#{options[:name]}.conf", 'upstart.conf', options
65
+ def self.configure_upstart(session, options)
66
+ session.upload_template! "/etc/init/#{options[:name]}.conf", 'upstart.conf', options
70
67
  end
71
68
  end
72
69
  end
data/lib/escualo/base.rb CHANGED
@@ -1,20 +1,41 @@
1
1
  module Escualo
2
2
  module Base
3
- def self.install_base(ssh, options)
4
- ssh.shell.perform! %q{
5
- apt-get install -y \
6
- autoconf \
7
- bison \
8
- build-essential \
9
- libreadline6 \
10
- libreadline6-dev \
11
- curl \
12
- git \
13
- libssl-dev \
14
- zlib1g \
15
- zlib1g-dev \
16
- libreadline-dev
17
- }, options
3
+ DEPS = %w(autoconf bison build-essential libreadline6 libreadline6-dev
4
+ curl git libssl-dev zlib1g zlib1g-dev libreadline-dev software-properties-common wget ca-certificates sudo upstart)
5
+
6
+ def self.install(session)
7
+ Escualo::AptGet.install session, DEPS.join(' ')
18
8
  end
9
+
10
+ def self.add_repositories(session)
11
+ session.tell_all! 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list',
12
+ 'wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -'
13
+
14
+ session.tell_all! 'echo "deb http://www.rabbitmq.com/debian testing main" >> /etc/apt/sources.list',
15
+ 'wget --quiet -O - https://www.rabbitmq.com/rabbitmq-signing-key-public.asc | apt-key add -'
16
+
17
+ session.tell! %Q{echo 'deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse' | tee /etc/apt/sources.list.d/mongodb-org-3.2.list}
18
+ session.tell! %Q{apt-add-repository '#{Escualo::PPA.for 'brightbox/ruby-ng'}'}
19
+ session.tell! %Q{add-apt-repository '#{Escualo::PPA.for 'nginx/stable'}'}
20
+
21
+ session.tell! 'apt-get update'
22
+ end
23
+
24
+ def self.configure_locales(session)
25
+ session.tell_all! 'apt-get purge -y locales',
26
+ "echo 'locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8' |debconf-set-selections",
27
+ "echo 'locales locales/default_environment_locale select en_US.UTF-8' | debconf-set-selections"
28
+ Escualo::AptGet.install session, 'locales', update: true
29
+ end
30
+
31
+ def self.enable_swap(session)
32
+ session.tell_all! 'test -e /swapfile || fallocate -l 4 G /swapfile',
33
+ 'chmod 600 /swapfile',
34
+ 'mkswap /swapfile',
35
+ 'swapon /swapfile',
36
+ 'swapon -s',
37
+ %Q{echo '/swapfile none swap sw 0 0' >> /etc/ fstab}
38
+ end
39
+
19
40
  end
20
41
  end
data/lib/escualo/env.rb CHANGED
@@ -1,59 +1,49 @@
1
1
  module Escualo
2
2
  module Env
3
- def self.setup(ssh)
3
+ def self.setup(session)
4
4
  source_escualorc = "'source ~/.escualorc'"
5
- ssh.exec! %Q{
6
- mkdir -p ~/.escualo/vars && \
7
- echo 'for var in ~/.escualo/vars/*; do source $var; done' > ~/.escualorc && \
8
- chmod u+x ~/.escualorc && \
9
- grep -q #{source_escualorc} ~/.bashrc || echo #{source_escualorc} >> ~/.bashrc
10
- }
5
+ session.tell_all! 'mkdir -p ~/.escualo/vars',
6
+ %q{echo 'for var in ~/.escualo/vars/*; do source $var; done' > ~/.escualorc},
7
+ %q{chmod u+x ~/.escualorc},
8
+ "grep -q #{source_escualorc} ~/.bashrc || echo #{source_escualorc} >> ~/.bashrc"
11
9
  end
12
10
 
13
- def self.set_locale(ssh, options)
14
- ssh.perform! "locale-gen #{locale} && update-locale LANG=#{locale}", options
11
+ def self.set_builtins(session, options)
12
+ set session, ESCUALO_BASE_VERSION: Escualo::BASE_VERSION
13
+ set session, Escualo::Env.locale_variables
14
+ set session, Escualo::Env.environment_variables(options.env)
15
15
  end
16
16
 
17
- def self.set_builtins(ssh, options)
18
- set ssh, ESCUALO_BASE_VERSION: Escualo::BASE_VERSION
19
- set ssh, Escualo::Env.locale_variables
20
- set ssh, Escualo::Env.environment_variables(options.env)
17
+ def self.list(session)
18
+ session.ask('cat ~/.escualo/vars/*').gsub('export ', '')
21
19
  end
22
20
 
23
- def self.list(ssh)
24
- ssh.exec!("cat ~/.escualo/vars/*").gsub("export ", '')
21
+ def self.clean(session, options)
22
+ session.tell! 'rm ~/.escualo/vars/*'
23
+ set_builtins session, options
25
24
  end
26
25
 
27
- def self.clean(ssh, options)
28
- options.env = get(ssh, 'RACK_ENV').split('=').second.strip
29
- ssh.exec!("rm ~/.escualo/vars/*")
30
- set_builtins ssh, options
31
- end
32
-
33
- def self.present?(ssh, variable)
34
- value = get(ssh, variable)
35
- value.present?
26
+ def self.present?(session, variable)
27
+ get(session, variable).present?
36
28
  rescue
37
29
  false
38
30
  end
39
31
 
40
- def self.get(ssh, variable)
41
- ssh.exec!("cat ~/.escualo/vars/#{variable}")
32
+ def self.get(session, variable)
33
+ session.ask("cat ~/.escualo/vars/#{variable}")
42
34
  end
43
35
 
44
- def self.set(ssh, variables)
45
- variables.each do |key, value|
46
- ssh.exec!(set_command key, value)
47
- end
36
+ def self.set(session, variables)
37
+ session.tell_all! *variables.map { |key, value| set_command key, value }
48
38
  end
49
39
 
50
40
  def self.set_command(key, value)
51
41
  "echo export #{key}=#{value} > ~/.escualo/vars/#{key}"
52
42
  end
53
43
 
54
- def self.unset(ssh, variable_names)
44
+ def self.unset(session, variable_names)
55
45
  variable_names.each do |name|
56
- ssh.exec!("rm ~/.escualo/vars/#{name}")
46
+ session.tell!("rm ~/.escualo/vars/#{name}")
57
47
  end
58
48
  end
59
49
 
data/lib/escualo/gems.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  module Escualo::Gems
2
- def self.install(ssh, options)
3
- ssh.shell.perform! "gem install bundler && gem install escualo -v #{Escualo::VERSION}", options
2
+ def self.install(session)
3
+ session.tell! "gem install bundler && gem install escualo -v #{Escualo::VERSION}"
4
4
  end
5
5
 
6
- def self.present?(ssh)
7
- ssh.shell.exec!('escualo --version').include? "escualo #{Escualo::VERSION}"
6
+ def self.installed?(session)
7
+ session.check? 'escualo --version', "escualo #{Escualo::VERSION}"
8
8
  end
9
9
  end
@@ -1,11 +1,11 @@
1
1
  module Escualo::Plugin
2
2
  class Docker
3
- def run(ssh, options)
4
- ssh.perform! 'apt-get install -y docker.io', options
3
+ def run(session, _options)
4
+ Escualo::AptGet.install session, 'docker.io'
5
5
  end
6
6
 
7
- def check(ssh, _options)
8
- ssh.exec!('docker -v').include? 'Docker version' rescue false
7
+ def installed?(session, _options)
8
+ session.check? 'docker -v', 'Docker version'
9
9
  end
10
10
  end
11
11
  end
@@ -1,11 +1,11 @@
1
1
  module Escualo::Plugin
2
2
  class Haskell
3
- def run(ssh, options)
4
- ssh.perform! 'apt-get install -y haskell-platform', options
3
+ def run(session, _options)
4
+ Escualo::AptGet.install session, 'haskell-platform'
5
5
  end
6
6
 
7
- def check(ssh, _options)
8
- ssh.exec!('ghc --version').include? 'The Glorious Glasgow Haskell Compilation System' rescue false
7
+ def installed?(session, _options)
8
+ session.check? 'ghc --version', 'The Glorious Glasgow Haskell Compilation System'
9
9
  end
10
10
  end
11
11
  end
@@ -1,17 +1,13 @@
1
1
  module Escualo::Plugin
2
2
  class Mongo
3
- def run(ssh, options)
4
- ssh.shell.perform! %Q{
5
- echo 'deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse' | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list && \
6
- apt-get update && \
7
- apt-get install -y --force-yes mongodb-org && \
8
- echo '' >> /etc/init/mongodb && \
9
- echo 'respawn' >> /etc/init/mongodb
10
- }, options
3
+ def run(session, _options)
4
+ Escualo::AptGet.install session, 'mongodb-org'
5
+ session.tell_all! "echo '' >> /etc/init/mongodb",
6
+ "echo 'respawn' >> /etc/init/mongodb"
11
7
  end
12
8
 
13
- def check(ssh, _options)
14
- ssh.shell.exec!('mongod --version').include? 'db version v3.2' rescue false
9
+ def installed?(session, _options)
10
+ session.check? 'mongod --version', 'db version v3.2'
15
11
  end
16
12
  end
17
13
  end
@@ -1,24 +1,23 @@
1
1
  module Escualo::Plugin
2
2
  class Monit
3
- def run(ssh, options)
4
- ssh.perform! %Q{
5
- apt-get install monit
6
- service monit stop
7
- cd /tmp &&
8
- wget https://mmonit.com/monit/dist/binary/5.16/monit-#{options.monit_version}-linux-x64.tar.gz &&
9
- tar -xzf monit-#{options.monit_version}-linux-x64.tar.gz &&
10
- cp monit-#{options.monit_version}/bin/monit /usr/bin/monit
11
- ln -s /etc/monit/monitrc /etc/monitrc
12
- service monit start
13
- echo 'set httpd port 2812 and' > /etc/monit/conf.d/web-server
14
- echo ' allow 0.0.0.0/0.0.0.0' >> /etc/monit/conf.d/web-server
15
- echo ' allow admin:#{options.monit_password}' >> /etc/monit/conf.d/web-server
16
- monit reload
17
- }, options
3
+ def run(session, options)
4
+ Escualo::AptGet.install session, 'monit'
5
+
6
+ session.tell_all! 'service monit stop',
7
+ 'cd /tmp',
8
+ "wget https://mmonit.com/monit/dist/binary/5.16/monit-#{options.monit_version}-linux-x64.tar.gz",
9
+ "tar -xzf monit-#{options.monit_version}-linux-x64.tar.gz",
10
+ "cp monit-#{options.monit_version}/bin/monit /usr/bin/monit",
11
+ 'ln -s /etc/monit/monitrc /etc/monitrc',
12
+ 'service monit start',
13
+ "echo 'set httpd port 2812 and' > /etc/monit/conf.d/web-server",
14
+ "echo ' allow 0.0.0.0/0.0.0.0' >> /etc/monit/conf.d/web-server",
15
+ "echo ' allow admin:#{options.monit_password}' >> /etc/monit/conf.d/web-server",
16
+ "monit reload"
18
17
  end
19
18
 
20
- def check(ssh, options)
21
- ssh.shell.exec!('monit --version').include? 'This is Monit version 5' rescue false
19
+ def installed?(session, options)
20
+ session.tell!('monit --version').include? 'This is Monit version 5' rescue false
22
21
  end
23
22
  end
24
23
  end
@@ -1,19 +1,16 @@
1
1
  module Escualo::Plugin
2
2
  class Nginx
3
- def run(ssh, options)
3
+ def run(session, options)
4
4
  config = options.nginx_conf.try { |it| File.read it }
5
5
 
6
- ssh.perform! %Q{
7
- sudo add-apt-repository #{Escualo::PPA.for 'nginx/stable'} &&
8
- sudo apt-get update &&
9
- sudo apt-get install nginx -y &&
10
- #{config ? "/etc/nginx/nginx.conf < cat #{config} && " : ''}
11
- service nginx restart
12
- }, options
6
+ Escualo::AptGet.install session, 'nginx'
7
+
8
+ session.tell_all! "#{config ? "/etc/nginx/nginx.conf < cat #{config} && " : ''}",
9
+ 'service nginx restart'
13
10
  end
14
11
 
15
- def check(ssh, _options)
16
- ssh.exec!('nginx -v').include? 'nginx version: nginx/1' rescue false
12
+ def installed?(session, _options)
13
+ session.check? 'nginx -v', 'nginx version: nginx/1'
17
14
  end
18
15
  end
19
16
  end
@@ -1,15 +1,13 @@
1
1
  module Escualo::Plugin
2
2
  class Node
3
- def run(ssh, options)
4
- ssh.shell.perform! %Q{
5
- curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.30.2/install.sh | bash && \
6
- source ~/.bashrc && \
7
- nvm install 4.2.4
8
- }, options
3
+ def run(session, _options)
4
+ session.tell_all! 'curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.30.2/install.sh | bash',
5
+ 'source ~/.bashrc',
6
+ 'nvm install 4.2.4'
9
7
  end
10
8
 
11
- def check(ssh, _options)
12
- ssh.shell.exec!('nvm use node').include? 'Now using node v4.2.4' rescue false
9
+ def installed?(session, _options)
10
+ session.tell!('nvm use node').include? 'Now using node v4.2.4' rescue false
13
11
  end
14
12
  end
15
13
  end
@@ -0,0 +1,26 @@
1
+ module Escualo::Plugin
2
+ class Postgres
3
+ def run(session, options)
4
+ raise 'missing pg-username' unless options.pg_username
5
+ raise 'missing pg-password' unless options.pg_password
6
+
7
+ pg_hba_conf = "/etc/postgresql/#{options.pg_version}/main/pg_hba.conf"
8
+
9
+ Escualo::AptGet.install session, "postgresql-#{options.pg_version} libpq-dev"
10
+
11
+ session.tell_all! "echo 'local all postgres peer' > #{pg_hba_conf}",
12
+ "echo 'local all postgres peer' >> #{pg_hba_conf}",
13
+ "echo 'local all all password' >> #{pg_hba_conf}",
14
+ "echo 'host all all 127.0.0.1/32 md5' >> #{pg_hba_conf}"
15
+
16
+ session.tell_all! '/etc/init.d/postgresql restart',
17
+ 'cd /',
18
+ "echo \"create role #{options.pg_username} with createdb login password '#{options.pg_password}';\" | sudo -u postgres PGDATABASE='' psql"
19
+ end
20
+
21
+
22
+ def installed?(session, options)
23
+ session.check? 'psql --version', "psql (PostgreSQL) #{options.pg_version}"
24
+ end
25
+ end
26
+ end
@@ -1,22 +1,17 @@
1
1
  module Escualo::Plugin
2
2
  class Rabbit
3
- def run(ssh, options)
4
- raise 'missing rabbit password' unless options.rabbit_admin_password
3
+ def run(session, options)
4
+ raise 'missing rabbit-admin-password' unless options.rabbit_admin_password
5
5
 
6
- ssh.shell.perform! %Q{
7
- echo "deb http://www.rabbitmq.com/debian testing main" >> /etc/apt/sources.list && \
8
- wget https://www.rabbitmq.com/rabbitmq-signing-key-public.asc && \
9
- apt-key add rabbitmq-signing-key-public.asc && \
10
- apt-get update && \
11
- apt-get install rabbitmq-server -y --force-yes && \
12
- rabbitmq-plugins enable rabbitmq_management && \
13
- rabbitmqctl add_user admin #{options.rabbit_admin_password} && \
14
- rabbitmqctl set_user_tags admin administrator
15
- }, options
6
+ Escualo::AptGet.install session, 'rabbitmq-server'
7
+
8
+ session.tell_all! 'rabbitmq-plugins enable rabbitmq_management',
9
+ "rabbitmqctl add_user admin #{options.rabbit_admin_password}",
10
+ 'rabbitmqctl set_user_tags admin administrator'
16
11
  end
17
12
 
18
- def check(ssh, _options)
19
- ssh.exec!('rabbitmq-server').include? 'node with name "rabbit" already running' rescue false
13
+ def installed?(session, _options)
14
+ session.check? 'rabbitmq-server', 'node with name "rabbit" already running'
20
15
  end
21
16
  end
22
17
  end
@@ -5,11 +5,6 @@ module Escualo
5
5
  def self.load(name)
6
6
  "Escualo::Plugin::#{name.capitalize}".constantize.new
7
7
  end
8
-
9
- def self.run_and_check(plugin, ssh, options)
10
- plugin.run ssh, options
11
- plugin.check ssh, options
12
- end
13
8
  end
14
9
  end
15
10
 
@@ -19,5 +14,5 @@ require_relative './plugin/haskell'
19
14
  require_relative './plugin/mongo'
20
15
  require_relative './plugin/nginx'
21
16
  require_relative './plugin/node'
22
- require_relative './plugin/postgre'
17
+ require_relative './plugin/postgres'
23
18
  require_relative './plugin/rabbit'
@@ -1,38 +1,36 @@
1
1
  module Escualo
2
2
  module Remote
3
- def self.attach(dir, name)
4
- remote_name = "escualo-#{name}-#{$hostname}"
5
- remote_url = remote_git_url(name)
6
- %x{cd #{dir} && git remote add #{remote_name} #{remote_url}}
3
+ def self.attach(session, dir, name, session_options)
4
+ remote_name = "escualo-#{name}-#{session_options.hostname}"
5
+ remote_url = remote_git_url(name, session_options)
6
+ session.tell! "cd #{dir} && git remote add #{remote_name} #{remote_url}"
7
7
  end
8
8
 
9
- def self.remote_git_url(name)
10
- if $ssh_remote
11
- "ssh://#{$username}@#{$hostname}:#{$ssh_port}/var/repo/#{name}.git"
12
- else
9
+ def self.remote_git_url(name, session_options)
10
+ if session_options.local || session_options.dockerized
13
11
  "/var/repo/#{name}.git"
12
+ else
13
+ "ssh://#{session_options.username}@#{session_options.hostname}:#{session_options.ssh_options[:port]}/var/repo/#{name}.git"
14
14
  end
15
15
  end
16
16
 
17
- def self.clone(dir, repo, options)
17
+ def self.clone(session, dir, repo, options)
18
18
  repo_url = "https://github.com/#{repo}"
19
- %x{git clone #{repo_url} #{dir}}
19
+ session.tell! "git clone #{repo_url} #{dir}"
20
20
  if options.tag
21
- %x{cd #{dir} && git checkout #{options.tag}}
21
+ session.tell! "cd #{dir} && git checkout #{options.tag}"
22
22
  end
23
23
  end
24
24
 
25
- def self.remotes(dir)
26
- %x{cd #{dir} && git remote show}
27
- .split
28
- .select {|it| it.start_with? 'escualo-'}
25
+ def self.remotes(session, dir)
26
+ session
27
+ .ask("cd #{dir} && git remote show")
28
+ .split
29
+ .select { |it| it.start_with? 'escualo-' }
29
30
  end
30
31
 
31
- def self.push(dir)
32
- remotes(dir)
33
- .each do |remote|
34
- %x{cd #{dir} && git push #{remote} HEAD}
35
- end
32
+ def self.push(session, dir)
33
+ session.tell! "cd #{dir} && for r in $(git remote show | grep escualo-); do git push $r HEAD; done"
36
34
  end
37
35
  end
38
36
  end
@@ -0,0 +1,17 @@
1
+ module Escualo
2
+ module Ruby
3
+ def self.install(session, options)
4
+ session.tell! 'apt-get purge libruby* -y'
5
+ if options.with_rbenv
6
+ session.tell_all! 'curl https://raw.githubusercontent.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash',
7
+ %Q{echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc},
8
+ %Q{echo 'eval "$(rbenv init -)"' >> ~/.bashrc}
9
+ session.tell_all! 'rbenv install 2.3.1',
10
+ 'rbenv global 2.3.1',
11
+ 'rbenv rehash'
12
+ else
13
+ Escualo::AptGet.install session, 'ruby2.3 ruby2.3-dev'
14
+ end
15
+ end
16
+ end
17
+ end