escualo 0.9.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3bf366a2ccdefdd9c7d0763c4c3dcee51957e733
4
- data.tar.gz: f0359ce5d57083e5322fdd6c5176a3ba85c54f36
3
+ metadata.gz: 9ca67b509144fad6dbaf8a507cb5caeb31dc07dc
4
+ data.tar.gz: 22bd4bb34946705c6a8e285ff831e374a1283337
5
5
  SHA512:
6
- metadata.gz: cf1e12413710310f5645da34bdd221755c70895c5f1b41d5309f2f2d6c42c6b3f848fbe044000f48a8c9e817c2af66cab5ff710e74f62284312e279ea187a162
7
- data.tar.gz: 367a8ef0bc7a27840a904693da66aa56ab5273e3a5d8f3faf9cfd6da730eb3633566a2cc4a7e9caa0d3c0c054cc4737a34d96fb00fa2a440b27e7c992c0d31c1
6
+ metadata.gz: 5dd59f3fe505e7d01b68fccf8a2ed86013fdf88df85673f55367504f4918558a48521a3676e0f95a7b854d29e0de9565d2369b2b6734c7796495ef87bd2937e2
7
+ data.tar.gz: f9d999c5a5245c8935b3607b566791e151d01c3f52de8ef0f594be1dfa53eedad2fa4b3fbc529625c4c948d8b126c300cc693e39fa08b29fbbb98732562ae391
@@ -15,7 +15,12 @@ command 'artifact destroy' do |c|
15
15
  name = args.first
16
16
 
17
17
  Escualo::Artifact.destroy(ssh, name)
18
- say "#{name} destroyed successfully"
18
+
19
+ if !Escualo::Artifact.present? ssh, name
20
+ say "#{name} destroyed successfully"
21
+ else
22
+ abort "Could not destroy artifact #{name}"
23
+ end
19
24
  end
20
25
  end
21
26
 
@@ -1,28 +1,15 @@
1
- def ask_monit_password(options)
2
- password = ask('Monit Password: ') { |q| q.echo = '*' }
3
- options.default monit_password: password
4
- end
5
-
6
1
  command 'bootstrap' do |c|
7
2
  c.syntax = 'escualo bootstrap'
8
3
  c.description = 'Prepare environment to be an escualo host'
9
4
  c.option '--swap', TrueClass, 'Setup swap?'
10
- c.option '--monit-version VERSION', String, 'Monit version'
11
- c.option '--monit-password PASSWORD', String, 'Monit password. Will be prompted otherwise'
12
- c.option '--no-monit', TrueClass, 'Skip monit installation'
13
5
  c.option '--env ENVIRONMENT', String, 'Environment. Valid options are development and production. default is production'
14
6
  c.option '--with-rbenv', TrueClass, 'Use rbenv instead of native ruby installation'
15
-
16
7
  c.option '-f', '--force', TrueClass, 'Force bootstrap even if already done?'
17
8
 
18
9
  c.ssh_action do |_args, options, ssh|
19
- ask_monit_password(options) unless options.monit_password || options.no_monit
20
- options.default monit_version: '5.16',
21
- env: 'production'
10
+ options.default env: 'production'
22
11
 
23
- do_unless Escualo::Env.present?(ssh, :ESCUALO_BASE_VERSION),
24
- 'This host has already been bootstrapped',
25
- options do
12
+ do_unless Escualo::Bootstrap.check(ssh), 'This host has already been bootstrapped', options do
26
13
  step 'Configuring variables...' do
27
14
  Escualo::Env.setup ssh
28
15
  Escualo::Env.set_builtins ssh, options
@@ -33,23 +20,19 @@ command 'bootstrap' do |c|
33
20
  Escualo::Bootstrap.install_ruby ssh, options
34
21
  end
35
22
 
36
- step 'Installing and configuring monit...' do
37
- Escualo::Bootstrap.setup_monit ssh, options
38
- end unless options.no_monit
39
-
40
23
  step 'Enabling swap...' do
41
24
  Escualo::Bootstrap.enable_swap ssh
42
25
  end if options.swap
43
26
 
44
27
  step 'Installing gems...' do
45
- Escualo::Bootstrap.install_gems ssh, options
28
+ Escualo::Gems.install ssh, options
46
29
  end
47
30
 
48
31
  step 'Setup artifact directories...' do
49
32
  Escualo::Artifact.setup ssh
50
33
  end
51
34
 
52
- if Escualo::Env.present?(ssh, :ESCUALO_BASE_VERSION)
35
+ if Escualo::Bootstrap.check ssh
53
36
  say 'Host bootstrapped successfully '
54
37
  else
55
38
  abort 'bootstrapping failed'
@@ -2,12 +2,18 @@ command 'plugin install' do |c|
2
2
  c.syntax = 'escualo plugin install <plugin>'
3
3
  c.description = "Install plugin on host. Valid plugins are #{Escualo::Plugin::PLUGINS.join(', ')}"
4
4
  c.option '--nginx-conf FILENAME', String, 'ningix config file, only for nginx plugin'
5
+
5
6
  c.option '--rabbit-admin-password PASSWORD', String, 'rabbitmq admin password, only for rabbit plugin'
7
+
6
8
  c.option '--pg-version VERSION', String, 'PostgreSQL major and minor version. Default is 9.3, only for postgre plugin'
7
9
 
10
+ c.option '--monit-version VERSION', String, 'Monit version. Default is 5.16'
11
+ c.option '--monit-password PASSWORD', String, 'Monit password. Required with monit plugin'
12
+
8
13
  c.option '-f', '--force', TrueClass, 'Force reinstalling even if already done'
9
14
  c.ssh_action do |args, options, ssh|
10
- options.default pg_version: '9.3'
15
+ options.default pg_version: '9.3',
16
+ monit_version: '5.16'
11
17
 
12
18
  plugin = args.first
13
19
  say "Installing #{plugin}"
@@ -16,13 +16,13 @@ command 'script' do |c|
16
16
  mode.start! options
17
17
 
18
18
  file = YAML.load_file args.first
19
+
19
20
  local_ssh = Net::SSH::Connection::LocalSession.new
20
21
  delegated_options = Escualo::Script.delegated_options options
21
22
 
22
23
  step 'Running local commands...' do
23
24
  mode.run_commands_for! file['local'], delegated_options, local_ssh, options
24
25
  end
25
-
26
26
  step 'Running remote commands...' do
27
27
  Net::SSH.with_session(ssh_session_options) do |ssh|
28
28
  mode.run_commands_for! file['remote'], ssh, options
@@ -11,7 +11,6 @@ module Escualo
11
11
  libreadline6-dev \
12
12
  curl \
13
13
  git \
14
- monit \
15
14
  libssl-dev \
16
15
  zlib1g \
17
16
  zlib1g-dev \
@@ -48,24 +47,8 @@ module Escualo
48
47
  echo '/swapfile none swap sw 0 0' >> /etc/fstab}
49
48
  end
50
49
 
51
- def self.setup_monit(ssh, options)
52
- ssh.perform! %Q{
53
- service monit stop
54
- cd /tmp &&
55
- wget https://mmonit.com/monit/dist/binary/5.16/monit-#{options.monit_version}-linux-x64.tar.gz &&
56
- tar -xzf monit-#{options.monit_version}-linux-x64.tar.gz &&
57
- cp monit-#{options.monit_version}/bin/monit /usr/bin/monit
58
- ln -s /etc/monit/monitrc /etc/monitrc
59
- service monit start
60
- echo 'set httpd port 2812 and' > /etc/monit/conf.d/web-server
61
- echo ' allow 0.0.0.0/0.0.0.0' >> /etc/monit/conf.d/web-server
62
- echo ' allow admin:#{options.monit_password}' >> /etc/monit/conf.d/web-server
63
- monit reload
64
- }, options
65
- end
66
-
67
- def self.install_gems(ssh, options)
68
- ssh.shell.perform! 'gem install bundler && gem install escualo', options
50
+ def self.check(ssh)
51
+ Escualo::Env.present?(ssh, :ESCUALO_BASE_VERSION) && Escualo::Gems.present?(ssh)
69
52
  end
70
53
  end
71
54
  end
data/lib/escualo/env.rb CHANGED
@@ -28,7 +28,9 @@ module Escualo
28
28
 
29
29
  def self.present?(ssh, variable)
30
30
  value = get(ssh, variable)
31
- value.present? && !value.include?('No such file or directory')
31
+ value.present?
32
+ rescue
33
+ false
32
34
  end
33
35
 
34
36
  def self.get(ssh, variable)
@@ -0,0 +1,9 @@
1
+ module Escualo::Gems
2
+ def self.install(ssh, options)
3
+ ssh.shell.perform! 'gem install bundler && gem install escualo', options
4
+ end
5
+
6
+ def self.present?(ssh)
7
+ ssh.shell.exec!('escualo --version').include? "escualo #{Escualo::VERSION}"
8
+ end
9
+ end
@@ -0,0 +1,24 @@
1
+ module Escualo::Plugin
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
18
+ end
19
+
20
+ def check(ssh, options)
21
+ ssh.shell.exec!('monit --version').include? 'This is Monit version 5'
22
+ end
23
+ end
24
+ end
@@ -1,6 +1,6 @@
1
1
  module Escualo
2
2
  module Plugin
3
- PLUGINS = %w(node haskell docker postgre nginx rabbit mongo)
3
+ PLUGINS = %w(node haskell docker postgre nginx rabbit mongo monit)
4
4
 
5
5
  def self.load(name)
6
6
  "Escualo::Plugin::#{name.capitalize}".constantize.new
@@ -14,6 +14,7 @@ module Escualo
14
14
  end
15
15
 
16
16
  require_relative './plugin/docker'
17
+ require_relative './plugin/monit'
17
18
  require_relative './plugin/haskell'
18
19
  require_relative './plugin/mongo'
19
20
  require_relative './plugin/nginx'
@@ -1,4 +1,4 @@
1
1
  module Escualo
2
- VERSION = '0.9.1'
2
+ VERSION = '1.0.0'
3
3
  BASE_VERSION = '3.2'
4
4
  end
data/lib/escualo.rb CHANGED
@@ -19,6 +19,7 @@ require_relative './ssh'
19
19
  require_relative './escualo/version'
20
20
  require_relative './escualo/env'
21
21
  require_relative './escualo/ppa'
22
+ require_relative './escualo/gems'
22
23
  require_relative './escualo/bootstrap'
23
24
  require_relative './escualo/script'
24
25
  require_relative './escualo/plugin'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: escualo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Franco Leonardo Bulgarelli
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '3.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: docker-api
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  description: |-
112
126
  escualo.rb is command-line tools that implements of the escualo provisioning format used by Mumuki Platform.
113
127
  It allows to deploy mumuki artifacts to any host
@@ -134,10 +148,12 @@ files:
134
148
  - lib/escualo/artifact.rb
135
149
  - lib/escualo/bootstrap.rb
136
150
  - lib/escualo/env.rb
151
+ - lib/escualo/gems.rb
137
152
  - lib/escualo/plugin.rb
138
153
  - lib/escualo/plugin/docker.rb
139
154
  - lib/escualo/plugin/haskell.rb
140
155
  - lib/escualo/plugin/mongo.rb
156
+ - lib/escualo/plugin/monit.rb
141
157
  - lib/escualo/plugin/nginx.rb
142
158
  - lib/escualo/plugin/node.rb
143
159
  - lib/escualo/plugin/postgre.rb