dreamcat4-moonshadow 0.0.2 → 0.0.3
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.
- data/app_generators/moonshine/moonshine_generator.rb +22 -22
- data/app_generators/moonshine/templates/rails/deploy.rb +3 -3
- data/app_generators/moonshine/templates/rails/manifest.rb +9 -9
- data/app_generators/moonshine/templates/rails/moonshine.rake +6 -6
- data/app_generators/moonshine/templates/rails/moonshine.yml +3 -3
- data/app_generators/moonshine/templates/readme.templates +1 -1
- data/app_generators/moonshine_plugin/USAGE +3 -3
- data/app_generators/moonshine_plugin/moonshine_plugin_generator.rb +5 -5
- data/app_generators/moonshine_plugin/templates/README.rdoc +3 -3
- data/app_generators/moonshine_plugin/templates/spec.rb +1 -1
- data/app_generators/moonshine_plugin/templates/spec_helper.rb +1 -1
- data/bin/moonshine +3 -3
- data/bin/moonshine_plugin +3 -3
- data/lib/moonshine/capistrano.rb +20 -20
- data/lib/moonshine/manifest/rails/apache.rb +1 -1
- data/lib/moonshine/manifest/rails/mysql.rb +5 -5
- data/lib/moonshine/manifest/rails/os.rb +4 -4
- data/lib/moonshine/manifest/rails/passenger.rb +1 -1
- data/lib/moonshine/manifest/rails/postgresql.rb +1 -1
- data/lib/moonshine/manifest/rails/rails.rb +14 -14
- data/lib/moonshine/manifest/rails/sqlite3.rb +1 -1
- data/lib/moonshine/manifest/rails.rb +10 -10
- data/lib/moonshine/manifest.rb +14 -14
- data/lib/moonshine.rb +3 -3
- data/lib/moonshine_setup_manifest.rb +5 -5
- metadata +2 -3
@@ -1,15 +1,15 @@
|
|
1
1
|
require 'tempfile'
|
2
|
-
class
|
3
|
-
attr_reader :file_name, :klass_name, :is_rails_app, :
|
2
|
+
class MoonshadowGenerator < RubiGen::Base
|
3
|
+
attr_reader :file_name, :klass_name, :is_rails_app, :moonshadow_version
|
4
4
|
|
5
5
|
def initialize(runtime_args, runtime_options = {})
|
6
6
|
super
|
7
|
-
@destination_root = args.shift
|
7
|
+
@destination_root = args.shift || "."
|
8
8
|
@file_name = "application_manifest"
|
9
9
|
@klass_name = @file_name.classify
|
10
10
|
@is_rails_app = detect_rails
|
11
|
-
gem '
|
12
|
-
@
|
11
|
+
gem 'moonshadow'
|
12
|
+
@moonshadow_version = Gem.loaded_specs["moonshadow"].version.to_s
|
13
13
|
end
|
14
14
|
|
15
15
|
# Override with your own usage banner.
|
@@ -22,8 +22,8 @@ class MoonshineGenerator < RubiGen::Base
|
|
22
22
|
directories(m)
|
23
23
|
m.template 'readme.templates', 'app/manifests/templates/README'
|
24
24
|
m.template 'Capfile', 'Capfile'
|
25
|
-
m.template "#{application_type}/
|
26
|
-
m.template "#{application_type}/
|
25
|
+
m.template "#{application_type}/moonshadow.yml", "config/moonshadow.yml"
|
26
|
+
m.template "#{application_type}/moonshadow.rake", 'lib/tasks/moonshadow.rake'
|
27
27
|
m.template 'rails/gems.yml', 'config/gems.yml', :assigns => { :gems => gems } if is_rails_app
|
28
28
|
generate_or_upgrade_manifest(m)
|
29
29
|
generate_or_upgrade_deploy(m)
|
@@ -37,9 +37,9 @@ protected
|
|
37
37
|
def intro
|
38
38
|
intro = <<-INTRO
|
39
39
|
|
40
|
-
After the
|
40
|
+
After the Moonshadow generator finishes don't forget to:
|
41
41
|
|
42
|
-
- Edit config/
|
42
|
+
- Edit config/moonshadow.yml
|
43
43
|
Use this file to manage configuration related to deploying and running the app:
|
44
44
|
domain name, git repos, package dependencies for gems, and more.
|
45
45
|
|
@@ -94,37 +94,37 @@ define the server 'stack', cron jobs, mail aliases, configuration files
|
|
94
94
|
#generate or upgrade app/manifests/#{file_name}.rb
|
95
95
|
def generate_or_upgrade_manifest(m)
|
96
96
|
if File.exists?(destination_path("app/manifests/#{file_name}.rb"))
|
97
|
-
if File.read(destination_path("app/manifests/#{file_name}.rb")) =~ /vendor\/plugins\/
|
98
|
-
gsub_file "app/manifests/#{file_name}.rb", /^.*vendor\/plugins\/
|
99
|
-
"#{
|
97
|
+
if File.read(destination_path("app/manifests/#{file_name}.rb")) =~ /vendor\/plugins\/moonshadow/
|
98
|
+
gsub_file "app/manifests/#{file_name}.rb", /^.*vendor\/plugins\/moonshadow.*$/mi do |match|
|
99
|
+
"#{moonshadow_gem_string}\nrequire 'moonshadow'\n"
|
100
100
|
end
|
101
101
|
else
|
102
|
-
gsub_file "app/manifests/#{file_name}.rb", /^gem '
|
103
|
-
|
102
|
+
gsub_file "app/manifests/#{file_name}.rb", /^gem 'moonshadow'.*$/mi do |match|
|
103
|
+
moonshadow_gem_string
|
104
104
|
end
|
105
105
|
end
|
106
106
|
else
|
107
|
-
m.template "#{application_type}/manifest.rb", "app/manifests/#{file_name}.rb", :assigns => { :
|
107
|
+
m.template "#{application_type}/manifest.rb", "app/manifests/#{file_name}.rb", :assigns => { :moonshadow_gem_string => moonshadow_gem_string }
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
111
|
#generate or upgrade config/deploy.rb
|
112
112
|
def generate_or_upgrade_deploy(m)
|
113
113
|
if File.exists?(destination_path('config/deploy.rb'))
|
114
|
-
if File.read(destination_path('config/deploy.rb')) =~ /
|
115
|
-
gsub_file 'config/deploy.rb', /^gem '
|
116
|
-
|
114
|
+
if File.read(destination_path('config/deploy.rb')) =~ /moonshadow\/capistrano/
|
115
|
+
gsub_file 'config/deploy.rb', /^gem 'moonshadow'.*$/mi do |match|
|
116
|
+
moonshadow_gem_string
|
117
117
|
end
|
118
118
|
else
|
119
|
-
File.prepend(destination_path('config/deploy.rb'), "#{
|
119
|
+
File.prepend(destination_path('config/deploy.rb'), "#{moonshadow_gem_string}\nrequire 'moonshadow/capistrano'\n")
|
120
120
|
end
|
121
121
|
else
|
122
|
-
m.template "#{application_type}/deploy.rb", 'config/deploy.rb', :assigns => { :
|
122
|
+
m.template "#{application_type}/deploy.rb", 'config/deploy.rb', :assigns => { :moonshadow_gem_string => moonshadow_gem_string }
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
126
|
-
def
|
127
|
-
"gem '
|
126
|
+
def moonshadow_gem_string
|
127
|
+
"gem 'moonshadow', '= #{moonshadow_version}'"
|
128
128
|
end
|
129
129
|
|
130
130
|
def gsub_file(relative_destination, regexp, *args, &block)
|
@@ -1,3 +1,3 @@
|
|
1
|
-
<%=
|
2
|
-
require '
|
3
|
-
server "
|
1
|
+
<%= moonshadow_gem_string %>
|
2
|
+
require 'moonshadow/capistrano'
|
3
|
+
server "moonshadow-managed-server.com", :app, :web, :db, :primary => true
|
@@ -1,15 +1,15 @@
|
|
1
|
-
<%=
|
2
|
-
require '
|
3
|
-
class <%= klass_name %> <
|
4
|
-
# The majority of your configuration should be in <tt>config/
|
1
|
+
<%= moonshadow_gem_string %>
|
2
|
+
require 'moonshadow'
|
3
|
+
class <%= klass_name %> < Moonshadow::Manifest::Rails
|
4
|
+
# The majority of your configuration should be in <tt>config/moonshadow.yml</tt>
|
5
5
|
# If necessary, you may provide extra configuration directly in this class
|
6
6
|
# using the configure method. The hash passed to the configure method is deep
|
7
|
-
# merged with what is in <tt>config/
|
7
|
+
# merged with what is in <tt>config/moonshadow.yml</tt>. This could be used,
|
8
8
|
# for example, to store passwords and/or private keys outside of your SCM, or
|
9
9
|
# to query a web service for configuration data.
|
10
10
|
#
|
11
11
|
# In the example below, the value configuration[:custom][:random] can be used in
|
12
|
-
# your
|
12
|
+
# your moonshadow settings or templates.
|
13
13
|
#
|
14
14
|
# require 'net/http'
|
15
15
|
# require 'json'
|
@@ -19,14 +19,14 @@ class <%= klass_name %> < Moonshine::Manifest::Rails
|
|
19
19
|
# })
|
20
20
|
|
21
21
|
# The default_stack recipe install Rails, Apache, Passenger, the database from
|
22
|
-
# database.yml, Postfix, Cron, logrotate and NTP. See lib/
|
22
|
+
# database.yml, Postfix, Cron, logrotate and NTP. See lib/moonshadow/manifest/rails.rb
|
23
23
|
# for details. To customize, remove this recipe and specify the components you want.
|
24
24
|
recipe :default_stack
|
25
25
|
|
26
26
|
# Add your application's custom requirements here
|
27
27
|
def application_packages
|
28
|
-
# If you've already told
|
29
|
-
# :apt_gems in <tt>
|
28
|
+
# If you've already told Moonshadow about a package required by a gem with
|
29
|
+
# :apt_gems in <tt>moonshadow.yml</tt> you do not need to include it here.
|
30
30
|
# package 'some_native_package', :ensure => :installed
|
31
31
|
|
32
32
|
# some_rake_task = "/usr/bin/rake -f #{configuration[:deploy_to]}/current/Rakefile custom:task RAILS_ENV=#{ENV['RAILS_ENV']}"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
namespace :
|
1
|
+
namespace :moonshadow do
|
2
2
|
|
3
3
|
namespace :db do
|
4
4
|
desc "Bootstrap the database with fixtures from db/boostrap."
|
@@ -43,8 +43,8 @@ namespace :moonshine do
|
|
43
43
|
|
44
44
|
rake db:schema:load (if db/schema.rb exists)
|
45
45
|
rake db:migrate (if db/migrate exists)
|
46
|
-
rake
|
47
|
-
rake
|
46
|
+
rake moonshadow:db:bootstrap (if db/bootstrap/ exists)
|
47
|
+
rake moonshadow:app:bootstrap
|
48
48
|
|
49
49
|
All of this assumes one things. That your application can run 'rake
|
50
50
|
environment' with an empty database. Please ensure your application can do
|
@@ -54,11 +54,11 @@ namespace :moonshine do
|
|
54
54
|
Rake::Task["db:schema:load"].invoke if File.exist?("db/schema.rb")
|
55
55
|
Rake::Task["environment"].invoke
|
56
56
|
Rake::Task["db:migrate"].invoke if File.exist?("db/migrate")
|
57
|
-
Rake::Task["
|
58
|
-
Rake::Task["
|
57
|
+
Rake::Task["moonshadow:db:bootstrap"].invoke if File.exist?("db/bootstrap")
|
58
|
+
Rake::Task["moonshadow:app:bootstrap"].invoke
|
59
59
|
end
|
60
60
|
|
61
|
-
desc "Update config/
|
61
|
+
desc "Update config/moonshadow.yml with a list of the required gems"
|
62
62
|
task :gems => 'gems:base' do
|
63
63
|
gem_array = Rails.configuration.gems.reject(&:frozen?).map do |gem|
|
64
64
|
hash = { :name => gem.name }
|
@@ -25,16 +25,16 @@
|
|
25
25
|
- log
|
26
26
|
- pids
|
27
27
|
- config
|
28
|
-
# After specifying a gem with config.gem, run 'rake
|
28
|
+
# After specifying a gem with config.gem, run 'rake moonshadow:gems'
|
29
29
|
# to update config/gems.yml. If the gem depends on native packages,
|
30
|
-
# tell
|
30
|
+
# tell Moonshadow here:
|
31
31
|
#:apt_gems:
|
32
32
|
# :awesomegem:
|
33
33
|
# - awesome
|
34
34
|
# - libawesome-dev
|
35
35
|
#
|
36
36
|
# See all the options for Passenger, Apache vhosts, and MySQL in the
|
37
|
-
# respective templates:
|
37
|
+
# respective templates: moonshadow/lib/moonshadow/manifest/rails/templates
|
38
38
|
:passenger:
|
39
39
|
:max_pool_size: 3
|
40
40
|
:use_global_queue: true
|
@@ -1,4 +1,4 @@
|
|
1
|
-
Templates placed in this directory will be used by
|
1
|
+
Templates placed in this directory will be used by Moonshadow instead of the
|
2
2
|
default templates with the same name.
|
3
3
|
|
4
4
|
The default templates for MySQL, Passenger module config, Passenger vhosts, and logrotate can
|
@@ -1,8 +1,8 @@
|
|
1
1
|
Description:
|
2
|
-
Generate a
|
2
|
+
Generate a Moonshadow plugin to provide new, reusable functionality in your manifest.
|
3
3
|
|
4
4
|
Example:
|
5
|
-
|
5
|
+
moonshadow_plugin iptables
|
6
6
|
|
7
7
|
This will create the plugin structure at:
|
8
|
-
vendor/plugins/
|
8
|
+
vendor/plugins/moonshadow_iptables
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class
|
1
|
+
class MoonshadowPluginGenerator < RubiGen::Base
|
2
2
|
attr_reader :name, :plugin_name, :module_name
|
3
3
|
|
4
4
|
def initialize(runtime_args, runtime_options = {})
|
@@ -8,10 +8,10 @@ class MoonshinePluginGenerator < RubiGen::Base
|
|
8
8
|
if plugin
|
9
9
|
@name = plugin.downcase.underscore
|
10
10
|
@module_name = @name.camelize
|
11
|
-
@plugin_name = '
|
11
|
+
@plugin_name = 'moonshadow_' + name
|
12
12
|
else
|
13
13
|
puts "Please specify the name of your plugin"
|
14
|
-
puts "
|
14
|
+
puts "moonshadow_plugin <name>"
|
15
15
|
puts
|
16
16
|
exit
|
17
17
|
end
|
@@ -21,8 +21,8 @@ class MoonshinePluginGenerator < RubiGen::Base
|
|
21
21
|
record do |m|
|
22
22
|
m.directory "vendor/plugins/#{plugin_name}"
|
23
23
|
m.template "README.rdoc", "vendor/plugins/#{plugin_name}/README.rdoc"
|
24
|
-
m.directory "vendor/plugins/#{plugin_name}/
|
25
|
-
m.template 'init.rb', "vendor/plugins/#{plugin_name}/
|
24
|
+
m.directory "vendor/plugins/#{plugin_name}/moonshadow"
|
25
|
+
m.template 'init.rb', "vendor/plugins/#{plugin_name}/moonshadow/init.rb"
|
26
26
|
m.directory "vendor/plugins/#{plugin_name}/lib"
|
27
27
|
m.template 'plugin.rb', "vendor/plugins/#{plugin_name}/lib/#{name}.rb"
|
28
28
|
m.directory "vendor/plugins/#{plugin_name}/spec"
|
@@ -1,6 +1,6 @@
|
|
1
|
-
=
|
1
|
+
= Moonshadow_<%= module_name %>
|
2
2
|
|
3
|
-
=== A plugin for
|
3
|
+
=== A plugin for Moonshadow[http://github.com/railsmachine/moonshadow]
|
4
4
|
|
5
5
|
A plugin for installing and managing <%= name %>.
|
6
6
|
|
@@ -9,6 +9,6 @@ A plugin for installing and managing <%= name %>.
|
|
9
9
|
* <tt>script/plugin install git://github.com/ACCOUNT/<%= plugin_name%>.git</tt>
|
10
10
|
* Configure settings if needed
|
11
11
|
configure(:<%= name %> => {:foo => true})
|
12
|
-
* Include the plugin and recipe(s) in your
|
12
|
+
* Include the plugin and recipe(s) in your Moonshadow manifest
|
13
13
|
plugin :<%= name %>
|
14
14
|
recipe :<%= name %>
|
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
ENV['RAILS_ENV'] = 'test'
|
3
3
|
ENV['RAILS_ROOT'] ||= File.dirname(__FILE__) + '/../../../..'
|
4
4
|
|
5
|
-
require File.join(File.dirname(__FILE__), '..', '..', '
|
5
|
+
require File.join(File.dirname(__FILE__), '..', '..', 'moonshadow', 'lib', 'moonshadow.rb')
|
6
6
|
require File.join(File.dirname(__FILE__), '..', 'lib', '<%= name %>.rb')
|
7
7
|
|
8
8
|
require 'shadow_puppet/test'
|
data/bin/moonshine
CHANGED
@@ -4,8 +4,8 @@ require 'rubygems'
|
|
4
4
|
require 'rubigen'
|
5
5
|
|
6
6
|
# if %w(-v --version).include? ARGV.first
|
7
|
-
# require '
|
8
|
-
# puts "#{File.basename($0)} #{
|
7
|
+
# require 'moonshadow/version'
|
8
|
+
# puts "#{File.basename($0)} #{Moonshadow::VERSION}"
|
9
9
|
# exit(0)
|
10
10
|
# end
|
11
11
|
|
@@ -14,4 +14,4 @@ source = RubiGen::PathSource.new(:application,
|
|
14
14
|
File.join(File.dirname(__FILE__), "../app_generators"))
|
15
15
|
RubiGen::Base.reset_sources
|
16
16
|
RubiGen::Base.append_sources source
|
17
|
-
RubiGen::Scripts::Generate.new.run(ARGV, :generator => '
|
17
|
+
RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'moonshadow')
|
data/bin/moonshine_plugin
CHANGED
@@ -4,8 +4,8 @@ require 'rubygems'
|
|
4
4
|
require 'rubigen'
|
5
5
|
|
6
6
|
# if %w(-v --version).include? ARGV.first
|
7
|
-
# require '
|
8
|
-
# puts "#{File.basename($0)} #{
|
7
|
+
# require 'moonshadow/version'
|
8
|
+
# puts "#{File.basename($0)} #{Moonshadow::VERSION}"
|
9
9
|
# exit(0)
|
10
10
|
# end
|
11
11
|
|
@@ -14,4 +14,4 @@ source = RubiGen::PathSource.new(:application,
|
|
14
14
|
File.join(File.dirname(__FILE__), "../app_generators"))
|
15
15
|
RubiGen::Base.reset_sources
|
16
16
|
RubiGen::Base.append_sources source
|
17
|
-
RubiGen::Scripts::Generate.new.run(ARGV, :generator => '
|
17
|
+
RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'moonshadow_plugin')
|
data/lib/moonshine/capistrano.rb
CHANGED
@@ -10,19 +10,19 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
10
10
|
|
11
11
|
after 'deploy:restart', 'deploy:cleanup'
|
12
12
|
|
13
|
-
#load the
|
13
|
+
#load the moonshadow configuration into
|
14
14
|
require 'yaml'
|
15
|
-
hash = YAML.load_file(File.join((ENV['RAILS_ROOT'] || Dir.pwd), 'config', '
|
15
|
+
hash = YAML.load_file(File.join((ENV['RAILS_ROOT'] || Dir.pwd), 'config', 'moonshadow.yml'))
|
16
16
|
hash.each do |key, value|
|
17
17
|
set(key.to_sym, value)
|
18
18
|
end
|
19
19
|
|
20
20
|
set :scm, :svn if !! repository =~ /^svn/
|
21
21
|
|
22
|
-
namespace :
|
22
|
+
namespace :moonshadow do
|
23
23
|
|
24
24
|
desc <<-DESC
|
25
|
-
Bootstrap a barebones Ubuntu system with Git, Ruby, RubyGems, and
|
25
|
+
Bootstrap a barebones Ubuntu system with Git, Ruby, RubyGems, and Moonshadow
|
26
26
|
dependencies. Called by deploy:setup.
|
27
27
|
DESC
|
28
28
|
task :bootstrap do
|
@@ -33,47 +33,47 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
33
33
|
|
34
34
|
task :setup_directories do
|
35
35
|
begin
|
36
|
-
config = YAML.load_file(File.join(Dir.pwd, 'config', '
|
37
|
-
put(YAML.dump(config),"/tmp/
|
36
|
+
config = YAML.load_file(File.join(Dir.pwd, 'config', 'moonshadow.yml'))
|
37
|
+
put(YAML.dump(config),"/tmp/moonshadow.yml")
|
38
38
|
rescue Exception => e
|
39
39
|
puts e
|
40
|
-
puts "Please make sure the settings in
|
40
|
+
puts "Please make sure the settings in moonshadow.yml are valid and that the target hostname is correct."
|
41
41
|
exit(0)
|
42
42
|
end
|
43
|
-
put(File.read(File.join(File.dirname(__FILE__), '..', '
|
44
|
-
sudo "shadow_puppet /tmp/
|
45
|
-
sudo 'rm /tmp/
|
46
|
-
sudo 'rm /tmp/
|
43
|
+
put(File.read(File.join(File.dirname(__FILE__), '..', 'moonshadow_setup_manifest.rb')),"/tmp/moonshadow_setup_manifest.rb")
|
44
|
+
sudo "shadow_puppet /tmp/moonshadow_setup_manifest.rb"
|
45
|
+
sudo 'rm /tmp/moonshadow_setup_manifest.rb'
|
46
|
+
sudo 'rm /tmp/moonshadow.yml'
|
47
47
|
end
|
48
48
|
|
49
49
|
task :ensure_installed do
|
50
50
|
begin
|
51
|
-
run "ruby -e 'require \"rubygems\"; gem \"
|
51
|
+
run "ruby -e 'require \"rubygems\"; gem \"moonshadow\", \"= #{Gem.loaded_specs["moonshadow"].version}\"' 2> /dev/null"
|
52
52
|
rescue
|
53
|
-
sudo "gem install
|
53
|
+
sudo "gem install moonshadow -v #{Gem.loaded_specs["moonshadow"].version}"
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
-
desc 'Apply the
|
57
|
+
desc 'Apply the Moonshadow manifest for this application'
|
58
58
|
task :apply do
|
59
59
|
on_rollback do
|
60
60
|
run "cd #{latest_release} && RAILS_ENV=#{fetch(:rails_env, 'production')} rake --trace environment"
|
61
61
|
end
|
62
62
|
ensure_installed
|
63
|
-
sudo "RAILS_ROOT=#{latest_release} DEPLOY_STAGE=#{ENV['DEPLOY_STAGE']||fetch(:stage,'undefined')} RAILS_ENV=#{fetch(:rails_env, 'production')} shadow_puppet #{latest_release}/app/manifests/#{fetch(:
|
64
|
-
sudo "touch /var/log/
|
63
|
+
sudo "RAILS_ROOT=#{latest_release} DEPLOY_STAGE=#{ENV['DEPLOY_STAGE']||fetch(:stage,'undefined')} RAILS_ENV=#{fetch(:rails_env, 'production')} shadow_puppet #{latest_release}/app/manifests/#{fetch(:moonshadow_manifest, 'application_manifest')}.rb"
|
64
|
+
sudo "touch /var/log/moonshadow_rake.log && cat /var/log/moonshadow_rake.log"
|
65
65
|
end
|
66
66
|
|
67
67
|
desc "Update code and then run a console. Useful for debugging deployment."
|
68
68
|
task :update_and_console do
|
69
|
-
set :
|
69
|
+
set :moonshadow_apply, false
|
70
70
|
deploy.update_code
|
71
71
|
app.console
|
72
72
|
end
|
73
73
|
|
74
74
|
desc "Update code and then run 'rake environment'. Useful for debugging deployment."
|
75
75
|
task :update_and_rake do
|
76
|
-
set :
|
76
|
+
set :moonshadow_apply, false
|
77
77
|
deploy.update_code
|
78
78
|
run "cd #{latest_release} && RAILS_ENV=#{fetch(:rails_env, 'production')} rake --trace environment"
|
79
79
|
end
|
@@ -85,7 +85,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
85
85
|
end
|
86
86
|
|
87
87
|
before 'deploy:symlink' do
|
88
|
-
apply if fetch(:
|
88
|
+
apply if fetch(:moonshadow_apply, true) == true
|
89
89
|
end
|
90
90
|
|
91
91
|
end
|
@@ -198,7 +198,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
198
198
|
will not destroy any deployed revisions or data.
|
199
199
|
DESC
|
200
200
|
task :setup, :except => { :no_release => true } do
|
201
|
-
|
201
|
+
moonshadow.bootstrap
|
202
202
|
vcs.install
|
203
203
|
end
|
204
204
|
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
module
|
1
|
+
module Moonshadow::Manifest::Rails::Mysql
|
2
2
|
|
3
3
|
# Installs <tt>mysql-server</tt> from apt and enables the <tt>mysql</tt>
|
4
4
|
# service. Also creates a configuration file at
|
5
|
-
# <tt>/etc/mysql/conf.d/
|
6
|
-
# <tt>templates/
|
5
|
+
# <tt>/etc/mysql/conf.d/moonshadow.cnf</tt>. See
|
6
|
+
# <tt>templates/moonshadow.cnf</tt> for configuration options.
|
7
7
|
def mysql_server
|
8
8
|
package 'mysql-server', :ensure => :installed
|
9
9
|
service 'mysql', :ensure => :running, :require => [
|
@@ -18,9 +18,9 @@ module Moonshine::Manifest::Rails::Mysql
|
|
18
18
|
:ensure => :present,
|
19
19
|
:content => template(File.join(File.dirname(__FILE__), 'templates', 'innodb.cnf.erb')),
|
20
20
|
:before => package('mysql-server')
|
21
|
-
file '/etc/mysql/conf.d/
|
21
|
+
file '/etc/mysql/conf.d/moonshadow.cnf',
|
22
22
|
:ensure => :present,
|
23
|
-
:content => template(File.join(File.dirname(__FILE__), 'templates', '
|
23
|
+
:content => template(File.join(File.dirname(__FILE__), 'templates', 'moonshadow.cnf.erb')),
|
24
24
|
:require => package('mysql-server'),
|
25
25
|
:notify => service('mysql')
|
26
26
|
file '/etc/logrotate.d/varlogmysql.conf', :ensure => :absent
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module Moonshadow::Manifest::Rails::Os
|
2
2
|
# Set up cron and enable the service. You can create cron jobs in your
|
3
3
|
# manifests like so:
|
4
4
|
#
|
@@ -17,10 +17,10 @@ module Moonshine::Manifest::Rails::Os
|
|
17
17
|
end
|
18
18
|
|
19
19
|
# Create a MOTD to remind those logging in via SSH that things are managed
|
20
|
-
# with
|
20
|
+
# with Moonshadow
|
21
21
|
def motd
|
22
22
|
motd_contents ="""-----------------
|
23
|
-
|
23
|
+
Moonshadow Managed
|
24
24
|
-----------------
|
25
25
|
|
26
26
|
Application: #{configuration[:application]}
|
@@ -30,7 +30,7 @@ Moonshine Managed
|
|
30
30
|
----------------
|
31
31
|
A Reminder
|
32
32
|
----------------
|
33
|
-
As the configuration of this server is managed with
|
33
|
+
As the configuration of this server is managed with Moonshadow, please refrain
|
34
34
|
from installing any gems, packages, or dependencies directly on the server.
|
35
35
|
----------------
|
36
36
|
"""
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# recipe :postgresql_server, :postgresql_gem, :postgresql_user, :postgresql_database
|
4
4
|
#
|
5
|
-
module
|
5
|
+
module Moonshadow::Manifest::Rails::Postgresql
|
6
6
|
|
7
7
|
# Installs <tt>postgresql</tt> from apt and enables the <tt>postgresql</tt>
|
8
8
|
# service.
|
@@ -1,6 +1,6 @@
|
|
1
|
-
module
|
1
|
+
module Moonshadow::Manifest::Rails::Rails
|
2
2
|
|
3
|
-
# Attempt to bootstrap your application. Calls <tt>rake
|
3
|
+
# Attempt to bootstrap your application. Calls <tt>rake moonshadow:bootstrap</tt>
|
4
4
|
# which runs:
|
5
5
|
#
|
6
6
|
# rake db:schema:load (if db/schema.rb exists)
|
@@ -8,19 +8,19 @@ module Moonshine::Manifest::Rails::Rails
|
|
8
8
|
#
|
9
9
|
# We then run a task to load bootstrap fixtures from <tt>db/bootstrap</tt>
|
10
10
|
# (if it exists). These fixtures may be created with the included
|
11
|
-
# <tt>
|
11
|
+
# <tt>moonshadow:db:bootstrap:dump</tt> rake task.
|
12
12
|
#
|
13
|
-
# rake
|
13
|
+
# rake moonshadow:db:bootstrap
|
14
14
|
#
|
15
15
|
# We then run the following task:
|
16
16
|
#
|
17
|
-
# rake
|
17
|
+
# rake moonshadow:app:bootstrap
|
18
18
|
#
|
19
|
-
# The <tt>
|
19
|
+
# The <tt>moonshadow:app:bootstrap</tt> task does nothing by default. If
|
20
20
|
# you'd like to have your application preform any logic on it's first deploy,
|
21
21
|
# overwrite this task in your <tt>Rakefile</tt>:
|
22
22
|
#
|
23
|
-
# namespace :
|
23
|
+
# namespace :moonshadow do
|
24
24
|
# namespace :app do
|
25
25
|
# desc "Overwrite this task in your app if you have any bootstrap tasks that need to be run"
|
26
26
|
# task :bootstrap do
|
@@ -33,7 +33,7 @@ module Moonshine::Manifest::Rails::Rails
|
|
33
33
|
# environment' with an empty database. Please ensure your application can do
|
34
34
|
# so!
|
35
35
|
def rails_bootstrap
|
36
|
-
rake '
|
36
|
+
rake 'moonshadow:bootstrap',
|
37
37
|
:alias => 'rails_bootstrap',
|
38
38
|
:refreshonly => true,
|
39
39
|
:before => exec('rake db:migrate')
|
@@ -59,28 +59,28 @@ module Moonshine::Manifest::Rails::Rails
|
|
59
59
|
# executes without error in your <tt>rails_root</tt>.
|
60
60
|
def rails_rake_environment
|
61
61
|
package 'rake', :provider => :gem, :ensure => :installed
|
62
|
-
file '/var/log/
|
62
|
+
file '/var/log/moonshadow_rake.log',
|
63
63
|
:ensure => :present,
|
64
64
|
:owner => configuration[:user],
|
65
65
|
:group => configuration[:group] || configuration[:user],
|
66
66
|
:mode => '775',
|
67
67
|
:content => ' '
|
68
68
|
exec 'rake tasks',
|
69
|
-
:command => 'rake environment >> /var/log/
|
69
|
+
:command => 'rake environment >> /var/log/moonshadow_rake.log 2>&1',
|
70
70
|
:user => configuration[:user],
|
71
71
|
:cwd => rails_root,
|
72
72
|
:environment => "RAILS_ENV=#{ENV['RAILS_ENV']}",
|
73
73
|
:require => [
|
74
74
|
exec('rails_gems'),
|
75
75
|
package('rake'),
|
76
|
-
file('/var/log/
|
76
|
+
file('/var/log/moonshadow_rake.log')
|
77
77
|
]
|
78
78
|
end
|
79
79
|
|
80
80
|
# Automatically install all gems needed specified in the array at
|
81
81
|
# <tt>configuration[:gems]</tt>. This loads gems from
|
82
82
|
# <tt>config/gems.yml</tt>, which can be generated from by running
|
83
|
-
# <tt>rake
|
83
|
+
# <tt>rake moonshadow:gems</tt> locally.
|
84
84
|
def rails_gems
|
85
85
|
gemrc = {
|
86
86
|
:verbose => true,
|
@@ -155,7 +155,7 @@ private
|
|
155
155
|
# <tt>libxslt1-dev</tt> because those are defined as dependencies for
|
156
156
|
# <tt>nokogiri</tt>.
|
157
157
|
#
|
158
|
-
# To define system dependencies not include in
|
158
|
+
# To define system dependencies not include in moonshadow:
|
159
159
|
#
|
160
160
|
# class UrManifest < ShadowPuppet::Manifest
|
161
161
|
# configure(:apt_gems => {
|
@@ -225,7 +225,7 @@ private
|
|
225
225
|
# app, with RAILS_ENV properly set
|
226
226
|
def rake(name, options = {})
|
227
227
|
exec("rake #{name}", {
|
228
|
-
:command => "rake #{name} >> /var/log/
|
228
|
+
:command => "rake #{name} >> /var/log/moonshadow_rake.log 2>&1",
|
229
229
|
:user => configuration[:user],
|
230
230
|
:cwd => rails_root,
|
231
231
|
:environment => "RAILS_ENV=#{ENV['RAILS_ENV']}",
|
@@ -1,14 +1,14 @@
|
|
1
1
|
#The Rails Manifest includes recipes for Apache, Mysql, Sqlite3 and Rails
|
2
2
|
#running on Ubuntu 8.04 or greater.
|
3
|
-
class
|
3
|
+
class Moonshadow::Manifest::Rails < Moonshadow::Manifest
|
4
4
|
def validate_platform
|
5
5
|
unless Facter.lsbdistid == 'Ubuntu' && Facter.lsbdistrelease.to_f >= 8.04
|
6
6
|
error = <<-ERROR
|
7
7
|
|
8
8
|
|
9
|
-
|
9
|
+
Moonshadow::Manifest::Rails is currently only supported on Ubuntu 8.04
|
10
10
|
or greater. If you'd like to see your favorite distro supported, fork
|
11
|
-
|
11
|
+
Moonshadow on GitHub!
|
12
12
|
ERROR
|
13
13
|
raise NotImplementedError, error
|
14
14
|
end
|
@@ -18,19 +18,19 @@ class Moonshine::Manifest::Rails < Moonshine::Manifest
|
|
18
18
|
configure(:apt_gems => YAML.load_file(File.join(File.dirname(__FILE__), 'rails', 'apt_gems.yml')))
|
19
19
|
|
20
20
|
require File.join(File.dirname(__FILE__), 'rails', 'passenger.rb')
|
21
|
-
include
|
21
|
+
include Moonshadow::Manifest::Rails::Passenger
|
22
22
|
require File.join(File.dirname(__FILE__), 'rails', 'mysql.rb')
|
23
|
-
include
|
23
|
+
include Moonshadow::Manifest::Rails::Mysql
|
24
24
|
require File.join(File.dirname(__FILE__), 'rails', 'postgresql.rb')
|
25
|
-
include
|
25
|
+
include Moonshadow::Manifest::Rails::Postgresql
|
26
26
|
require File.join(File.dirname(__FILE__), 'rails', 'sqlite3.rb')
|
27
|
-
include
|
27
|
+
include Moonshadow::Manifest::Rails::Sqlite3
|
28
28
|
require File.join(File.dirname(__FILE__), 'rails', 'apache.rb')
|
29
|
-
include
|
29
|
+
include Moonshadow::Manifest::Rails::Apache
|
30
30
|
require File.join(File.dirname(__FILE__), 'rails', 'rails.rb')
|
31
|
-
include
|
31
|
+
include Moonshadow::Manifest::Rails::Rails
|
32
32
|
require File.join(File.dirname(__FILE__), 'rails', 'os.rb')
|
33
|
-
include
|
33
|
+
include Moonshadow::Manifest::Rails::Os
|
34
34
|
|
35
35
|
# A super recipe for installing Apache, Passenger, a database,
|
36
36
|
# Rails, NTP, Cron, Postfix. To customize your stack, call the
|
data/lib/moonshine/manifest.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
# This is the base
|
2
|
-
# for loading
|
1
|
+
# This is the base Moonshadow Manifest class, which provides a simple system
|
2
|
+
# for loading moonshadow recpies from plugins, a template helper, and parses
|
3
3
|
# several configuration files:
|
4
4
|
#
|
5
|
-
# config/
|
5
|
+
# config/moonshadow.yml
|
6
6
|
#
|
7
|
-
# The contents of <tt>config/
|
7
|
+
# The contents of <tt>config/moonshadow.yml</tt> are expected to serialize into
|
8
8
|
# a hash, and are loaded into the manifest's Configatron::Store.
|
9
9
|
#
|
10
10
|
# config/database.yml
|
@@ -13,14 +13,14 @@
|
|
13
13
|
# <tt>configuration[:database]</tt>.
|
14
14
|
#
|
15
15
|
# If you'd like to create another 'default rails stack' using other tools that
|
16
|
-
# what
|
17
|
-
class
|
18
|
-
# Load a
|
16
|
+
# what Moonshadow::Manifest::Rails uses, subclass this and go nuts.
|
17
|
+
class Moonshadow::Manifest < ShadowPuppet::Manifest
|
18
|
+
# Load a Moonshadow Plugin
|
19
19
|
#
|
20
|
-
# class MyManifest <
|
20
|
+
# class MyManifest < Moonshadow::Manifest
|
21
21
|
#
|
22
|
-
# # Evals vendor/plugins/
|
23
|
-
# plugin :
|
22
|
+
# # Evals vendor/plugins/moonshadow_my_app/moonshadow/init.rb
|
23
|
+
# plugin :moonshadow_my_app
|
24
24
|
#
|
25
25
|
# # Evals lib/my_recipe.rb
|
26
26
|
# plugin 'lib/my_recipe.rb'
|
@@ -29,7 +29,7 @@ class Moonshine::Manifest < ShadowPuppet::Manifest
|
|
29
29
|
# end
|
30
30
|
def self.plugin(name = nil)
|
31
31
|
if name.is_a?(Symbol)
|
32
|
-
path = File.join(rails_root, 'vendor', 'plugins', '
|
32
|
+
path = File.join(rails_root, 'vendor', 'plugins', 'moonshadow_' + name.to_s, 'moonshadow', 'init.rb')
|
33
33
|
else
|
34
34
|
path = name
|
35
35
|
end
|
@@ -134,9 +134,9 @@ class Moonshine::Manifest < ShadowPuppet::Manifest
|
|
134
134
|
end
|
135
135
|
|
136
136
|
def self.initial_configuration
|
137
|
-
# config/
|
138
|
-
|
139
|
-
configure(YAML::load(ERB.new(
|
137
|
+
# config/moonshadow.yml
|
138
|
+
moonshadow_yml = IO.read(File.join(rails_root, 'config', 'moonshadow.yml')) rescue nil
|
139
|
+
configure(YAML::load(ERB.new(moonshadow_yml).result)) if moonshadow_yml
|
140
140
|
|
141
141
|
# database config
|
142
142
|
database_yml = IO.read(File.join(rails_root, 'config', 'database.yml')) rescue nil
|
data/lib/moonshine.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'shadow_puppet'
|
2
2
|
require 'erb'
|
3
3
|
require 'active_support/inflector'
|
4
|
-
module
|
4
|
+
module Moonshadow #:nodoc:
|
5
5
|
end
|
6
|
-
require File.join(File.dirname(__FILE__), '
|
7
|
-
require File.join(File.dirname(__FILE__), '
|
6
|
+
require File.join(File.dirname(__FILE__), 'moonshadow', 'manifest.rb')
|
7
|
+
require File.join(File.dirname(__FILE__), 'moonshadow', 'manifest', 'rails.rb')
|
@@ -1,14 +1,14 @@
|
|
1
|
-
# Running <tt>cap deploy:setup</tt> or <tt>cap
|
2
|
-
# in uploads your <p>config/
|
1
|
+
# Running <tt>cap deploy:setup</tt> or <tt>cap moonshadow:bootstrap</tt>
|
2
|
+
# in uploads your <p>config/moonshadow.yml</p> to <tt>/tmp/moonshadow.yml</tt>
|
3
3
|
# on your server and applies this manifest.
|
4
4
|
#
|
5
|
-
# Requires these three variables in a YAML <tt>config/
|
5
|
+
# Requires these three variables in a YAML <tt>config/moonshadow.yml</tt>:
|
6
6
|
#
|
7
7
|
# application: your_app_name
|
8
8
|
# user: rails
|
9
9
|
# deploy_to: /srv/your_app_name
|
10
|
-
class
|
11
|
-
configure(YAML.load_file('/tmp/
|
10
|
+
class MoonshadowSetupManifest < ShadowPuppet::Manifest
|
11
|
+
configure(YAML.load_file('/tmp/moonshadow.yml'))
|
12
12
|
|
13
13
|
recipe :directories
|
14
14
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dreamcat4-moonshadow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jesse Newland
|
@@ -106,7 +106,6 @@ files:
|
|
106
106
|
- LICENSE
|
107
107
|
has_rdoc: false
|
108
108
|
homepage: http://railsmachine.github.com/moonshine/
|
109
|
-
licenses:
|
110
109
|
post_install_message:
|
111
110
|
rdoc_options:
|
112
111
|
- --charset=UTF-8
|
@@ -127,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
126
|
requirements: []
|
128
127
|
|
129
128
|
rubyforge_project:
|
130
|
-
rubygems_version: 1.
|
129
|
+
rubygems_version: 1.2.0
|
131
130
|
signing_key:
|
132
131
|
specification_version: 3
|
133
132
|
summary: Rails deployment and configuration management done right. ShadowPuppet + Capistrano == crazy delicious
|