dolphin 0.1.3 → 0.1.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1f9f3b9fb1215ac9b545eaa9867df9279430e6ca
4
- data.tar.gz: 213425f42e5a6b40cf386cf1f160a85f2ddd3264
3
+ metadata.gz: f22c9016dc3dcf69da51f20c7bd9750876bcf40e
4
+ data.tar.gz: de8a214a9f9675c560e11cd9e611faf651c4aa8d
5
5
  SHA512:
6
- metadata.gz: 4ac99c14dc64a47fd0207cf19c8212ff1d592483dd5ec5ac85a4358f86d060bc86af015cb1d1134a027f5e10272aa5a70feb26b290a40409c695c6fdffed0dc8
7
- data.tar.gz: 3f376724b4f8fc15e73e2f6d72dda1359a1596670dd92016f2b4cc7929f6129d527121d38c90f442d3d1732ed1d76ec2897febe40a1aec2a1c0f07eb52aa0211
6
+ metadata.gz: 1135c650af4599c5cbf183bbc1e6038eccee75e45ba1f4f92934dafaa01658e83c44cd4e7ee20b4812ee18e3c0f88e42ebc6897d5df84417c0a50e3082aa879c
7
+ data.tar.gz: 6cbd3ec7df37ce3aa7426d5a2c4ffb816a39542ccca6babd14828cedd605486e6fab25cac6d517171862429bfff891f0d61cde500ccc02d4b0787a3c89a4df5d
data/README.md CHANGED
@@ -31,6 +31,13 @@ Or install it yourself as:
31
31
 
32
32
  $ gem install dolphin
33
33
 
34
+ ### Default dolphin executable
35
+ The dolphin gem comes with a minimal default executable, called 'dolphin', installed to the normal gem executable location (eg., ~/.gem/ruby/2.1.4/bin/dolphin). It is assumed to be running as the current user and in local host mode.
36
+
37
+ So it can be used to run various tasks on the local host. For example:
38
+
39
+ $ dolphin setup gems
40
+
34
41
  ### Generator for dolphin executable
35
42
 
36
43
  Run generator from your Rails application:
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+ require "dolphin"
3
+
4
+ class Dolphin::Base
5
+
6
+ private
7
+
8
+ # deployment environments
9
+ def env
10
+ # internal variables, no need to change by user
11
+ # -----------------------------
12
+ # ssh sessions
13
+ @sessions = {}
14
+
15
+ # only running in local mode
16
+ # by default, log in as yourself
17
+ @user = `whoami`.strip
18
+ # may log in as another user
19
+ # @user = 'neng'
20
+ @servers = [
21
+ 'localhost',
22
+ ]
23
+
24
+ # home dir as app_dir
25
+ @app_dir = '~'
26
+ end
27
+ end
28
+
29
+ # start the CLI
30
+ Dolphin::CLI.start
@@ -40,7 +40,7 @@ Gem::Specification.new do |spec|
40
40
  spec.add_dependency "net-ssh"
41
41
  spec.add_dependency "parallel"
42
42
 
43
- spec.add_development_dependency "bundler", "~> 1.3"
43
+ spec.add_development_dependency "bundler"
44
44
  spec.add_development_dependency "rake"
45
45
 
46
46
  end
@@ -2,7 +2,7 @@
2
2
  class Dolphin::Setup < Dolphin::Base
3
3
 
4
4
  desc "chruby", "install/update chruby"
5
- def chruby(version='v0.3.7')
5
+ def chruby(version='v0.3.8')
6
6
  menu = [
7
7
  "
8
8
  # git clone
@@ -13,7 +13,7 @@ class Dolphin::Setup < Dolphin::Base
13
13
  git checkout master
14
14
  git rebase origin/master
15
15
  # checkout tag
16
- git checkout #{version}
16
+ # git checkout #{version}
17
17
  # install
18
18
  sudo make install
19
19
  # system wise
@@ -49,7 +49,7 @@ class Dolphin::Setup < Dolphin::Base
49
49
  git checkout master
50
50
  git rebase origin/master
51
51
  # checkout tag
52
- git checkout #{version}
52
+ # git checkout #{version}
53
53
  # install
54
54
  sudo make install
55
55
  ",
@@ -84,11 +84,13 @@ class Dolphin::Setup < Dolphin::Base
84
84
  end
85
85
 
86
86
  desc "ruby", "install ruby, arg: version"
87
- def ruby(version="2.0.0-p247")
87
+ def ruby(version="ruby")
88
88
  menu = [
89
89
  "
90
+ # intall gem system wise
91
+ # sudo gem install bundler --no-user-install
90
92
  # install ruby
91
- sudo ruby-install ruby #{version}
93
+ sudo /usr/local/bin/ruby-install #{version}
92
94
  ",
93
95
  ]
94
96
 
@@ -96,26 +98,29 @@ class Dolphin::Setup < Dolphin::Base
96
98
  end
97
99
 
98
100
  desc "select", "select ruby, arg: version"
99
- def select(version="2.0.0-p247")
101
+ def select(version="ruby-2.1.4")
100
102
  menu = [
101
103
  "
102
104
  # select ruby
103
105
  cd #{@app_dir}
104
- echo ruby-#{version} > .ruby-version
106
+ echo #{version} > .ruby-version
105
107
  ",
106
108
  ]
107
109
 
108
110
  execute menu
109
111
  end
110
112
 
111
- desc "bundler", "install bundler"
112
- def bundler
113
+ desc "gems", "install default gems, arg: ruby"
114
+ def gems(ruby="ruby-2.1.4")
113
115
  menu = [
114
- "
115
- # install bundler
116
+ %{
116
117
  cd #{@app_dir}
117
- sudo gem install bundler
118
- ",
118
+ # switch to the target ruby
119
+ chruby #{ruby}
120
+ # first gem-ctags so latter gems can be tagged
121
+ gem install gem-ctags
122
+ gem install bundler pry dolphin letters specific_install fled did_you_mean
123
+ },
119
124
  ]
120
125
 
121
126
  execute menu
@@ -0,0 +1,200 @@
1
+ # graylog related tasks
2
+ class Dolphin::Graylog < Dolphin::Base
3
+
4
+ desc "srvi", "install graylog2 server"
5
+ def srvi
6
+ menu = [
7
+ %{
8
+ wget https://github.com/Graylog2/graylog2-server/releases/download/0.13.0-rc.1/graylog2-server-0.13.0-rc.1.tar.gz
9
+ tar xvfz graylog2-server-0.13.0-rc.1.tar.gz
10
+ cd graylog2-server-0.13.0-rc.1
11
+ sudo mv ~/graylog2-server-0.13.0-rc.1 /opt/graylog2-server
12
+ },
13
+ ]
14
+
15
+ execute menu
16
+ end
17
+
18
+ desc "srvc", "config graylog2 server"
19
+ def srvc
20
+ # upload files
21
+ upload("#{@config_root}/graylog/server/*", "/tmp")
22
+
23
+ clustername = @env
24
+ networkhost = @vpn_hash[:log]
25
+ unicasthost = @vpn_hash[:ela]
26
+ indexprefix = @env
27
+ mongodbdatabase = "#{@env}-graylog2"
28
+ mongodbreplicaset = @group_hash[:mg].map {|item| "#{@vpn_hash[item]}:27017"}.join(',')
29
+
30
+ menu = [
31
+ %{
32
+ # sed -i 's/CLUSTERNAME/#{clustername}/' /tmp/graylog2-elasticsearch.yml
33
+ sed -i 's/NETWORKHOST/#{networkhost}/' /tmp/graylog2-elasticsearch.yml
34
+ sed -i 's/UNICASTHOST/#{unicasthost}/' /tmp/graylog2-elasticsearch.yml
35
+ # sed -i 's/INDEXPREFIX/#{indexprefix}/' /tmp/graylog2.conf
36
+ # sed -i 's/MONGODBREPLICASET/#{mongodbreplicaset}/' /tmp/graylog2.conf
37
+ # sed -i 's/MONGODBDATABASE/#{mongodbdatabase}/' /tmp/graylog2.conf
38
+ sudo mv /tmp/graylog2* /etc
39
+ sudo chown root:root /etc/graylog2*
40
+ sudo mv /tmp/graylog.conf /etc/init/
41
+ sudo chown root:root /etc/init/graylog.conf
42
+ sudo mv /tmp/rails.conf /etc/init/
43
+ sudo chown root:root /etc/init/rails.conf
44
+ sudo restart graylog
45
+ },
46
+ ]
47
+
48
+ execute menu
49
+ end
50
+
51
+ desc "ufw", "config firewall"
52
+ def ufw
53
+ menu = [
54
+ %{
55
+ # graylog2
56
+ sudo ufw allow from 192.168.0.0/16 to any port 514
57
+ sudo ufw allow from 192.168.0.0/16 to any port 514
58
+ sudo ufw allow from 192.168.0.0/16 to any port 12201
59
+
60
+ # elasticsearch ports
61
+ sudo ufw allow from 192.168.0.0/16 to any port 9200
62
+ sudo ufw allow from 192.168.0.0/16 to any port 9300
63
+
64
+ # nginx
65
+ sudo ufw allow 'Nginx Full'
66
+ sudo ufw status numbered
67
+ },
68
+ ]
69
+
70
+ execute menu
71
+ end
72
+
73
+ desc "webi", "install graylog2 web interface"
74
+ def webi
75
+ menu = [
76
+ %{
77
+ # web interface
78
+ sudo mkdir #{@app_dir}
79
+ sudo chown #{@user}:#{@user_group} #{@app_dir}
80
+ cd #{@app_dir}
81
+ wget https://github.com/Graylog2/graylog2-web-interface/releases/download/0.12.0/graylog2-web-interface-0.12.0.tar.gz
82
+ tar xvfz graylog2-web-interface-0.12.0.tar.gz
83
+ mv graylog2-web-interface-0.12.0 graylog2
84
+ },
85
+ ]
86
+
87
+ execute menu
88
+
89
+ # manual steps
90
+ %{
91
+ bin/dolphin setup chruby -t log
92
+ bin/dolphin setup ruby_install -t log
93
+ bin/dolphin setup ruby -t log
94
+ bin/dolphin setup select -t log
95
+ bin/dolphin ubuntu user -t log
96
+ bin/dolphin setup bundler -t log
97
+
98
+ # add puma to Gemfile
99
+ sudo bundle install
100
+ # run rake secret
101
+ }
102
+ end
103
+
104
+ desc "webc", "config graylog2 web interface"
105
+ def webc
106
+ # upload files
107
+ upload("#{@config_root}/graylog/nginx/*", "/tmp/")
108
+ upload("#{@config_root}/graylog/rails/*", "#{@app_dir}/graylog2/config/")
109
+
110
+ servername = @server_hash[:log]
111
+ menu = [
112
+ %{
113
+ # nginx
114
+ sed -i 's/SERVERNAME/#{servername}/' /tmp/graylog2.conf
115
+ sudo mv /tmp/graylog2.conf /etc/nginx/sites-available/
116
+ sudo rm -f /etc/nginx/sites-enabled/default
117
+ sudo ln -sf /etc/nginx/sites-available/graylog2.conf /etc/nginx/sites-enabled
118
+ sudo service nginx restart
119
+ },
120
+ ]
121
+
122
+ execute menu
123
+
124
+ end
125
+
126
+ desc "webb", "begin graylog2 web interface"
127
+ def webb
128
+ menu = [
129
+ %{
130
+ source /usr/local/share/chruby/chruby.sh
131
+ source /usr/local/share/chruby/auto.sh
132
+ cd #{@deploy_dir}
133
+ RAILS_ENV=production bundle exec puma -C #{@deploy_dir}/config/puma.rb
134
+ },
135
+ ]
136
+
137
+ execute menu
138
+ end
139
+
140
+ desc "webs", "stop graylog2 web interface"
141
+ def webs
142
+ menu = [
143
+ %{
144
+ source /usr/local/share/chruby/chruby.sh
145
+ source /usr/local/share/chruby/auto.sh
146
+ cd #{@deploy_dir}
147
+ RAILS_ENV=production bundle exec pumactl -S #{@pids}/#{@application}.state stop
148
+ },
149
+ ]
150
+
151
+ execute menu
152
+ end
153
+
154
+ desc "webr", "restart graylog2 web interface"
155
+ def webr
156
+ menu = [
157
+ %{
158
+ source /usr/local/share/chruby/chruby.sh
159
+ source /usr/local/share/chruby/auto.sh
160
+ cd #{@deploy_dir}
161
+ RAILS_ENV=production bundle exec pumactl -S #{@pids}/#{@application}.state restart
162
+ },
163
+ ]
164
+
165
+ execute menu
166
+ end
167
+
168
+ private
169
+
170
+ # deployment environments
171
+ def env
172
+ # inherit general settings
173
+ super
174
+
175
+ # name of this application
176
+ @application = 'graylog2'
177
+ # on servers under @app_dir, the directory where this application resides
178
+ @deploy_dir = "#{@app_dir}/#{@application}"
179
+ # puma related settings
180
+ @pids = "#{@deploy_dir}/tmp/pids"
181
+
182
+ # ===================================
183
+ # settings to avoid simultaneous deployments
184
+ # ===================================
185
+
186
+ # current deployment will abort when another deployment is still in progress
187
+
188
+ # lead server for lock status
189
+ @lead_server = @servers[0]
190
+ # name and location of the lock file
191
+ @lock_file = "#{@deploy_dir}/tmp/pids/dolphin.lock"
192
+ # format of date/time for lock file
193
+ @deploy_date = Time.now.strftime("%m%d%H%M")
194
+ # custom content for the lock file
195
+ @lock_message = "Deploy started at #{@deploy_date} in progress\n"
196
+ # name and location of the head file to store git head info
197
+ @head_file = "#{@deploy_dir}/tmp/pids/head.txt"
198
+ end
199
+
200
+ end
@@ -4,12 +4,12 @@ class Dolphin::Mongodb < Dolphin::Base
4
4
  desc "install", "install mongodb"
5
5
  def install
6
6
  menu = [
7
- "
7
+ %{
8
8
  sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
9
9
  sudo echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/10gen.list
10
10
  sudo apt-get update
11
11
  sudo apt-get -y install mongodb-10gen
12
- ",
12
+ },
13
13
  ]
14
14
 
15
15
  execute menu
@@ -18,10 +18,10 @@ class Dolphin::Mongodb < Dolphin::Base
18
18
  desc "disable", "disable mongodb"
19
19
  def disable
20
20
  menu = [
21
- "
21
+ %{
22
22
  sudo stop mongodb
23
23
  sudo sh -c 'echo manual > /etc/init/mongodb.override'
24
- ",
24
+ },
25
25
  ]
26
26
 
27
27
  execute menu
@@ -30,10 +30,10 @@ class Dolphin::Mongodb < Dolphin::Base
30
30
  desc "enable", "enable mongodb"
31
31
  def enable
32
32
  menu = [
33
- "
33
+ %{
34
34
  sudo rm -f /etc/init/mongodb.override
35
35
  sudo start mongodb
36
- ",
36
+ },
37
37
  ]
38
38
 
39
39
  execute menu
@@ -0,0 +1,90 @@
1
+ # shinken related tasks
2
+ class Dolphin::Shinken < Dolphin::Base
3
+
4
+ desc "client", "shinken client config"
5
+ def client
6
+ # upload files
7
+ upload("#{@config_root}/shinken/client/*", "/tmp")
8
+
9
+ menu = [
10
+ %{
11
+ # sudo apt-get -y install snmpd
12
+ sudo mv /tmp/snmpd.conf /etc/snmp/
13
+ sudo chown root:root /etc/snmp/snmpd.conf
14
+ sudo service snmpd restart
15
+
16
+ },
17
+ ]
18
+
19
+ execute menu
20
+ end
21
+
22
+ desc "install", "install shinken server"
23
+ def install
24
+ menu = [
25
+ %{
26
+ wget http://www.shinken-monitoring.org/pub/shinken-1.4.tar.gz
27
+ tar -xvzf shinken-1.4.tar.gz
28
+ cd ~/shinken-1.4
29
+ sudo ./install -i
30
+
31
+ sudo ./install -h
32
+ sudo ./install -p nagios-plugins
33
+ sudo ./install -p check_mem
34
+ sudo ./install -p manubulon
35
+ sudo ./install -p check_snmp_bandwidth
36
+ sudo ./install -p check_snmp
37
+ sudo ./install -p check_netint
38
+ sudo ./install -p check_mongodb
39
+
40
+ sudo apt-get -y install nagios-plugins
41
+ # sudo ./install -a pnp4nagios
42
+ # sudo ./install -a mongodb # already installed
43
+
44
+ sudo update-rc.d mongodb enable
45
+ },
46
+ ]
47
+
48
+ execute menu
49
+ end
50
+
51
+ desc "config", "config shinken server"
52
+ def config
53
+ # template: etc/packs/os/linux
54
+ # upload files
55
+ upload("#{@config_root}/shinken/server/*", "/tmp")
56
+
57
+ menu = [
58
+ %{
59
+ sudo mv /tmp/nagios.cfg /usr/local/shinken/etc/
60
+ sudo mv /tmp/shinken-specific.cfg /usr/local/shinken/etc/
61
+ sudo mv /tmp/resource.cfg /usr/local/shinken/etc/
62
+ sudo mv /tmp/contacts.cfg /usr/local/shinken/etc/
63
+ sudo mv /tmp/commands.cfg /usr/local/shinken/etc/
64
+ sudo mv /tmp/templates.cfg /usr/local/shinken/etc/
65
+ sudo mv /tmp/staging.cfg /usr/local/shinken/etc/hosts/
66
+ sudo mv /tmp/production.cfg /usr/local/shinken/etc/hosts/
67
+ sudo mv /tmp/services.cfg /usr/local/shinken/etc/hosts/
68
+ sudo service shinken restart
69
+ },
70
+
71
+ ]
72
+
73
+ execute menu
74
+ end
75
+
76
+ desc "email", "install email client"
77
+ def email
78
+ menu = [
79
+ %{
80
+ sudo apt-get -y install libio-socket-ssl-perl libdigest-hmac-perl libterm-readkey-perl libmime-lite-perl libfile-libmagic-perl libio-socket-inet6-perl
81
+ sudo chown #{@user}:#{@user_group} #{@app_dir}
82
+ cd #{@app_dir}
83
+ if [ ! -d 'smtp-cli' ]; then git clone https://github.com/mludvig/smtp-cli.git ; fi
84
+ },
85
+ ]
86
+
87
+ execute menu
88
+ end
89
+
90
+ end
@@ -1,3 +1,3 @@
1
1
  module Dolphin
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,98 +1,100 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dolphin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neng Xu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-03 00:00:00.000000000 Z
11
+ date: 2014-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: net-ssh
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: parallel
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '1.3'
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '1.3'
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  description: 'Dolphin: deploy agilely like dolphins can swim. A multi-threaded multi-stage
84
84
  deployment tool utilizes the full power of Git and Ruby.'
85
85
  email:
86
86
  - neng2.xu2@gmail.com
87
- executables: []
87
+ executables:
88
+ - dolphin
88
89
  extensions: []
89
90
  extra_rdoc_files: []
90
91
  files:
91
- - .gitignore
92
+ - ".gitignore"
92
93
  - Gemfile
93
94
  - LICENSE.txt
94
95
  - README.md
95
96
  - Rakefile
97
+ - bin/dolphin
96
98
  - dolphin.gemspec
97
99
  - lib/dolphin.rb
98
100
  - lib/dolphin/base.rb
@@ -102,8 +104,10 @@ files:
102
104
  - lib/dolphin/nginx.rb
103
105
  - lib/dolphin/puma.rb
104
106
  - lib/dolphin/setup.rb
107
+ - lib/dolphin/ubuntu/graylog.rb
105
108
  - lib/dolphin/ubuntu/mongodb.rb
106
109
  - lib/dolphin/ubuntu/postgres.rb
110
+ - lib/dolphin/ubuntu/shinken.rb
107
111
  - lib/dolphin/version.rb
108
112
  - lib/generators/dolphin/install_generator.rb
109
113
  - lib/generators/dolphin/puma_generator.rb
@@ -128,17 +132,17 @@ require_paths:
128
132
  - lib
129
133
  required_ruby_version: !ruby/object:Gem::Requirement
130
134
  requirements:
131
- - - '>='
135
+ - - ">="
132
136
  - !ruby/object:Gem::Version
133
137
  version: '0'
134
138
  required_rubygems_version: !ruby/object:Gem::Requirement
135
139
  requirements:
136
- - - '>='
140
+ - - ">="
137
141
  - !ruby/object:Gem::Version
138
142
  version: '0'
139
143
  requirements: []
140
144
  rubyforge_project:
141
- rubygems_version: 2.0.3
145
+ rubygems_version: 2.2.2
142
146
  signing_key:
143
147
  specification_version: 4
144
148
  summary: 'Dolphin: deploy agilely like dolphins can swim. A multi-threaded multi-stage