mana 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/cookbooks/monit/files/ubuntu/monit.default +1 -11
- data/cookbooks/railsapp/recipes/backup.rb +24 -0
- data/lib/mana/capistrano.rb +27 -2
- data/lib/mana/server_ec2.rb +11 -0
- data/lib/mana/version.rb +1 -1
- data/templates/config/deploy.rb +5 -0
- metadata +13 -17
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 131c277ffa492ef0846fd6910eb048a2aa58cfbd
|
4
|
+
data.tar.gz: 8eeb92f6c22a350935d750f48e4ff54531057fee
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fc9239f7b25930b52472adc78dd91889b691bcfa6955045fcc3aff3d5600b71241aae7cf6d5ef88cae92637dcccb8782b4274ac1c7adb5b1317ea4a9f508333b
|
7
|
+
data.tar.gz: 252083d5a0a841414e92810882a9a77cfcff57549da1289d4060443a9a00c89168e616c7ab835b38a4595cbf56da56bb249adf37d339d7ecfc703fce2e6f36bd
|
@@ -1,11 +1 @@
|
|
1
|
-
|
2
|
-
# sourced by /etc/init.d/monit
|
3
|
-
# installed at /etc/default/monit by chef
|
4
|
-
|
5
|
-
# You must set this variable to for monit to start
|
6
|
-
startup=1
|
7
|
-
|
8
|
-
# To change the intervals which monit should run,
|
9
|
-
# edit the configuration file /etc/monit/monitrc
|
10
|
-
# It can no longer be configured here.
|
11
|
-
|
1
|
+
START=yes
|
@@ -0,0 +1,24 @@
|
|
1
|
+
package 's3cmd'
|
2
|
+
|
3
|
+
s3cfg_filepath = "#{node.deploy_to}/.s3cmd"
|
4
|
+
|
5
|
+
file s3cfg_filepath do
|
6
|
+
content <<CONTENT
|
7
|
+
[default]
|
8
|
+
access_key = #{node.aws.access_key_id}
|
9
|
+
secret_key = #{node.aws.secret_access_key}
|
10
|
+
CONTENT
|
11
|
+
end
|
12
|
+
|
13
|
+
bucket = "#{node.application}-backup"
|
14
|
+
|
15
|
+
execute "s3cmd -c #{s3cfg_filepath} mb s3://#{bucket}"
|
16
|
+
|
17
|
+
cron "#{node.application}-backup" do
|
18
|
+
server_id = node[:ec2] ? node.ec2.instance_id : node.hostname
|
19
|
+
|
20
|
+
minute 0
|
21
|
+
command "F=`mktemp` && pg_dump -c -U postgres #{node.railsapp.db_name} | gzip > $F && s3cmd -c #{s3cfg_filepath} put $F s3://#{bucket}/#{server_id}-#{node.railsapp.db_name}/`date -u +\\%Y-\\%m-\\%d/\\%H-\\%M-\\%S`.sql.gz && rm $F"
|
22
|
+
|
23
|
+
user node[:runner] || node.user
|
24
|
+
end
|
data/lib/mana/capistrano.rb
CHANGED
@@ -25,7 +25,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
25
25
|
|
26
26
|
# Roundsman fine-tuning
|
27
27
|
|
28
|
-
set :chef_version, '~>
|
28
|
+
set :chef_version, '~> 11.4.0'
|
29
29
|
set :cookbooks_directory, 'config/deploy/cookbooks'
|
30
30
|
set :stream_roundsman_output, false # todo check why is this needed
|
31
31
|
set :ruby_install_script do
|
@@ -97,6 +97,9 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
97
97
|
desc 'Install & update software'
|
98
98
|
task :install do
|
99
99
|
roundsman.chef.default
|
100
|
+
|
101
|
+
# fix https://github.com/iain/roundsman/issues/26
|
102
|
+
variables.keys.each { |k| reset! k }
|
100
103
|
end
|
101
104
|
|
102
105
|
desc 'Show install log'
|
@@ -121,10 +124,31 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
121
124
|
sudo "DEBIAN_FRONTEND=noninteractive #{fetch(:package_manager)} -yq upgrade"
|
122
125
|
end
|
123
126
|
|
127
|
+
set :ssh_login_options, '-L 3737:localhost:3737' # forward monit status server port
|
128
|
+
|
124
129
|
desc "Open SSH connection to server"
|
125
130
|
task :ssh do
|
126
131
|
host = roles[:app].servers.first # silly approach
|
127
|
-
exec "ssh
|
132
|
+
exec "ssh #{ssh_login_options} #{fetch(:user)}@#{host}"
|
133
|
+
end
|
134
|
+
|
135
|
+
def sudo_runner
|
136
|
+
(exists? :runner) ? (sudo as: runner) : ''
|
137
|
+
end
|
138
|
+
|
139
|
+
desc 'Run rails console'
|
140
|
+
task :console do
|
141
|
+
host = roles[:app].servers.first # silly approach
|
142
|
+
cmd = "cd #{current_path} && #{sudo_runner} bundle exec rails console #{rails_env}"
|
143
|
+
exec "ssh -t #{ssh_login_options} #{fetch(:user)}@#{host} #{cmd.shellescape}"
|
144
|
+
end
|
145
|
+
|
146
|
+
desc 'Run rake task. Example: cap mana:rake about'
|
147
|
+
task :rake do
|
148
|
+
host = roles[:app].servers.first # silly approach
|
149
|
+
args = ARGV.drop_while { |a| a != 'mana:rake' }[1..-1].join ' '
|
150
|
+
cmd = "cd #{current_path} && #{sudo_runner} RAILS_ENV=#{rails_env} bundle exec rake #{args}"
|
151
|
+
exec "ssh #{fetch(:user)}@#{host} #{cmd.shellescape}"
|
128
152
|
end
|
129
153
|
|
130
154
|
desc "Watch Rails log"
|
@@ -138,6 +162,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
138
162
|
exit
|
139
163
|
end
|
140
164
|
end
|
165
|
+
|
141
166
|
end
|
142
167
|
|
143
168
|
# More convinience
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'right_aws'
|
2
|
+
|
3
|
+
module Capistrano
|
4
|
+
class Configuration
|
5
|
+
def server_ec2 instance_id, *roles
|
6
|
+
ec2 = RightAws::Ec2.new aws[:access_key_id], aws[:secret_access_key]
|
7
|
+
addr = ec2.describe_instances(instance_id).first[:ip_address]
|
8
|
+
server addr, *roles
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
data/lib/mana/version.rb
CHANGED
data/templates/config/deploy.rb
CHANGED
@@ -27,6 +27,10 @@ set :monit,
|
|
27
27
|
set :railsapp,
|
28
28
|
server_names: '_' #TODO: change this to domain name(s) of the project
|
29
29
|
|
30
|
+
set :aws,
|
31
|
+
access_key_id: '',
|
32
|
+
secret_access_key: '' #TODO: set this to let railsapp::backup put backups in s3
|
33
|
+
|
30
34
|
# For other options look into cookbooks/*/attributes/default.rb
|
31
35
|
# and other cookbook sources.
|
32
36
|
|
@@ -36,6 +40,7 @@ set :run_list, %w(
|
|
36
40
|
recipe[postgresql]
|
37
41
|
recipe[nginx]
|
38
42
|
recipe[railsapp]
|
43
|
+
recipe[railsapp::backup]
|
39
44
|
)
|
40
45
|
|
41
46
|
after 'deploy:restart', 'deploy:restart_unicorn'
|
metadata
CHANGED
@@ -1,46 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mana
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.7
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Ilia Ablamonov, Cloud Castle Inc.
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-04-16 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: capistrano
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: roundsman
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
description: Configuration management with Chef & Capistrano
|
@@ -78,6 +73,7 @@ files:
|
|
78
73
|
- cookbooks/postgresql/templates/default/postgresql.conf.erb
|
79
74
|
- cookbooks/postgresql/templates/default/postgresql.monit.conf.erb
|
80
75
|
- cookbooks/railsapp/attributes/default.rb
|
76
|
+
- cookbooks/railsapp/recipes/backup.rb
|
81
77
|
- cookbooks/railsapp/recipes/default.rb
|
82
78
|
- cookbooks/railsapp/templates/default/master.monit.conf.erb
|
83
79
|
- cookbooks/railsapp/templates/default/site.conf.erb
|
@@ -88,6 +84,7 @@ files:
|
|
88
84
|
- lib/mana/capistrano.rb
|
89
85
|
- lib/mana/railtie.rb
|
90
86
|
- lib/mana/remote_cache_subdir.rb
|
87
|
+
- lib/mana/server_ec2.rb
|
91
88
|
- lib/mana/version.rb
|
92
89
|
- lib/tasks/mana.rake
|
93
90
|
- mana.gemspec
|
@@ -97,26 +94,25 @@ files:
|
|
97
94
|
- templates/config/deploy/vagrant.rb
|
98
95
|
homepage: https://github.com/cloudcastle/mana
|
99
96
|
licenses: []
|
97
|
+
metadata: {}
|
100
98
|
post_install_message:
|
101
99
|
rdoc_options: []
|
102
100
|
require_paths:
|
103
101
|
- lib
|
104
102
|
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
103
|
requirements:
|
107
|
-
- -
|
104
|
+
- - '>='
|
108
105
|
- !ruby/object:Gem::Version
|
109
106
|
version: '0'
|
110
107
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
-
none: false
|
112
108
|
requirements:
|
113
|
-
- -
|
109
|
+
- - '>='
|
114
110
|
- !ruby/object:Gem::Version
|
115
111
|
version: '0'
|
116
112
|
requirements: []
|
117
113
|
rubyforge_project:
|
118
|
-
rubygems_version:
|
114
|
+
rubygems_version: 2.0.3
|
119
115
|
signing_key:
|
120
|
-
specification_version:
|
116
|
+
specification_version: 4
|
121
117
|
summary: Configuration management with Chef & Capistrano
|
122
118
|
test_files: []
|