deprec-core 3.1.1 → 3.1.2

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/CHANGELOG ADDED
@@ -0,0 +1,7 @@
1
+ deprec-core changelog
2
+ =====================
3
+
4
+ = 3.1.2 (Jul 17, 2011)
5
+
6
+ * Extracted the guts of deprec into this gem
7
+
@@ -0,0 +1,68 @@
1
+ # Copyright 2006-2008 by Mike Bailey. All rights reserved.
2
+ # canonical.rb
3
+ #
4
+ # Running deprec:web:stop will be the same as running deprec:apache:stop or
5
+ # deprec:nginx:stop depending what you have chosen.
6
+ #
7
+ # generic namespaces are linked up to chosen applications at runtime but these
8
+ # stubs are so they'll be included in the output of "cap -T"
9
+ #
10
+ Capistrano::Configuration.instance(:must_exist).load do
11
+
12
+ %w(ruby).each do |package|
13
+ namespace "deprec:#{package}" do
14
+
15
+ desc "Install #{package.capitalize}"
16
+ task :install do
17
+ end
18
+
19
+ end
20
+ end
21
+
22
+ %w(web app db).each do |server|
23
+ namespace "deprec:#{server}" do
24
+
25
+ desc "Install #{server.capitalize} server"
26
+ task :install, :roles => server do
27
+ end
28
+
29
+ desc "Generate config file(s) for #{server} server from template(s)"
30
+ task :config_gen do
31
+ end
32
+
33
+ desc "Deploy configuration files(s) for #{server} server"
34
+ task :config, :roles => server do
35
+ end
36
+
37
+ desc "Start #{server} server"
38
+ task :start, :roles => server do
39
+ end
40
+
41
+ desc "Stop #{server} server"
42
+ task :stop, :roles => server do
43
+ end
44
+
45
+ desc "Stop #{server} server"
46
+ task :restart, :roles => server do
47
+ end
48
+
49
+ desc "Enable startup script for #{server} server"
50
+ task :activate, :roles => server do
51
+ end
52
+
53
+ desc "Disable startup script for #{server} server"
54
+ task :deactivate, :roles => server do
55
+ end
56
+
57
+ desc "Backup data for #{server} server"
58
+ task :backup, :roles => server do
59
+ end
60
+
61
+ desc "Restore data for #{server} server from backup"
62
+ task :restore, :roles => server do
63
+ end
64
+
65
+ end
66
+ end
67
+
68
+ end
@@ -13,6 +13,9 @@ module Deprec2
13
13
  ENV['ROLES'] = old_roles.to_s unless ENV['HOSTS']
14
14
  end
15
15
 
16
+ def rake_remote(task_name)
17
+ run "cd #{current_path} && RAILS_ENV=#{rails_env} #{rake} #{task_name}"
18
+ end
16
19
 
17
20
  # Temporarily ignore ROLES and HOSTS
18
21
  def ignoring_roles_and_hosts
@@ -0,0 +1,184 @@
1
+ # Copyright 2006-2011 by Mike Bailey. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+
4
+ # Connect deprec:db to deprec:mysql, deprec:web to deprec:apache, etc
5
+ on :load, 'deprec:connect_canonical_tasks'
6
+
7
+ # Set the value if not already set
8
+ # This method is accessible to all recipe files
9
+ # Defined and used by capistrano/deploy tasks
10
+ def _cset(name, *args, &block)
11
+ unless exists?(name)
12
+ set(name, *args, &block)
13
+ end
14
+ end
15
+
16
+ # deprecated
17
+ alias :default :_cset
18
+
19
+ _cset :rake, 'rake'
20
+
21
+ # Deprec checks here for local versions of config templates before it's own
22
+ _cset :local_template_dir, File.join('config','templates')
23
+
24
+ # The following two Constants contain details of the configuration
25
+ # files used by each service. They're used when generating config
26
+ # files from templates and when configs files are pushed out to servers.
27
+ #
28
+ # They are populated by the recipe file for each service
29
+ #
30
+ SYSTEM_CONFIG_FILES = {} # e.g. httpd.conf
31
+ PROJECT_CONFIG_FILES = {} # e.g. projectname-httpd-vhost.conf
32
+
33
+ # For each service, the details of the file to download and options
34
+ # to configure, build and install the service
35
+ SRC_PACKAGES = {} unless defined?(SRC_PACKAGES)
36
+
37
+ # deprec defines some generic recipes for common services
38
+ # including ruby interpreter, web, app and database servers
39
+ #
40
+ # They default to my current favourites which you can over ride
41
+ #
42
+ # Service options
43
+ CHOICES_RUBY_VM = [:mri, :ree]
44
+ CHOICES_WEBSERVER = [:apache, :none] # :nginx not recipes out of date
45
+ CHOICES_APPSERVER = [:passenger, :none] # any colour you like guys
46
+ CHOICES_DATABASE = [:mysql, :postgresql, :sqlite, :none]
47
+ #
48
+ # Service defaults
49
+ _cset :ruby_vm_type, :mri
50
+ _cset :web_server_type, :apache
51
+ _cset :app_server_type, :passenger
52
+ _cset :db_server_type, :mysql
53
+
54
+ # Prompt user for missing values if not supplied
55
+ _cset(:application) do
56
+ Capistrano::CLI.ui.ask "Enter name of project(no spaces)" do |q|
57
+ q.validate = /^[0-9a-z_]*$/
58
+ end
59
+ end
60
+
61
+ _cset(:domain) do
62
+ Capistrano::CLI.ui.ask "Enter domain name for project" do |q|
63
+ q.validate = /^[0-9a-z_\.]*$/
64
+ end
65
+ end
66
+
67
+ _cset(:repository) do
68
+ Capistrano::CLI.ui.ask "Enter repository URL for project" do |q|
69
+ # q.validate = //
70
+ end
71
+ end
72
+
73
+ _cset :backup_dir, '/var/backups'
74
+
75
+ # XXX rails deploy stuff
76
+ _cset :apps_root, '/srv' # parent dir for apps
77
+ _cset(:deploy_to) { File.join(apps_root, application) } # dir for current app
78
+ _cset(:current_path) { File.join(deploy_to, "current") }
79
+ _cset(:shared_path) { File.join(deploy_to, "shared") }
80
+
81
+ # XXX more rails deploy stuff?
82
+
83
+ _cset :user, ENV['USER'] # user who is deploying
84
+ _cset :group, 'deploy' # deployment group
85
+ _cset(:group_src) { group } # group ownership for src dir
86
+ _cset :src_dir, '/usr/local/src' # 3rd party src on servers lives here
87
+ _cset(:web_server_aliases) { domain.match(/^www/) ? [] : ["www.#{domain}"] }
88
+
89
+ # It can be useful to know the user running this command
90
+ # even when USER is set to someone else. Sorry windows!
91
+ _cset :current_user, `whoami`.chomp
92
+
93
+ namespace :deprec do
94
+
95
+ task :connect_canonical_tasks do
96
+ # link application specific recipes into canonical task names
97
+ # e.g. deprec:web:restart => deprec:nginx:restart
98
+
99
+
100
+ namespaces_to_connect = { :web => :web_server_type,
101
+ :app => :app_server_type,
102
+ :db => :db_server_type,
103
+ :ruby => :ruby_vm_type
104
+ }
105
+ metaclass = class << self; self; end # XXX unnecessary?
106
+ namespaces_to_connect.each do |server, choice|
107
+ server_type = send(choice).to_sym
108
+ if server_type != :none
109
+ metaclass.send(:define_method, server) { namespaces[server] } # XXX unnecessary?
110
+ namespaces[server] = deprec.send(server_type)
111
+ end
112
+ end
113
+ end
114
+
115
+ task :dump do
116
+ require 'yaml'
117
+ y variables
118
+ end
119
+
120
+ task :setup_src_dir do
121
+ deprec2.groupadd(group_src)
122
+ deprec2.add_user_to_group(user, group_src)
123
+ deprec2.create_src_dir
124
+ end
125
+
126
+ # Download all packages used by deprec to your local host.
127
+ # You can then push them to /usr/local/src on target hosts
128
+ # to save time and bandwidth rather than repeatedly downloading
129
+ # from the distribution sites.
130
+ task :update_src do
131
+ SRC_PACKAGES.each{|key, src_package|
132
+ current_dir = Dir.pwd
133
+ system "cd src/ && test -f #{src_package[:filename]} || wget --quiet --timestamping #{src_package[:url]}"
134
+ system "cd #{current_dir}"
135
+ }
136
+ end
137
+
138
+ # todo
139
+ #
140
+ # Copy files from src/ to /usr/local/src/ on remote hosts
141
+ task :push_src do
142
+ SRC_PACKAGES.each do |key, src_package|
143
+ deprec2.set_package_defaults(src_package)
144
+ file = File.join('src', src_package[:filename])
145
+ if File.exists?(file)
146
+ std.su_put(File.read(file), "#{src_dir}/#{src_package[:filename]}", '/tmp/')
147
+ end
148
+ end
149
+ end
150
+
151
+ task :list_src do
152
+ # XXX ugly line - look away
153
+ max_key_size = SRC_PACKAGES.keys.max{|a,b| a.to_s.size <=> b.to_s.size}.to_s.size
154
+ SRC_PACKAGES.each{|key, src_package|
155
+ deprec2.set_package_defaults(src_package)
156
+ puts "#{key}#{' '*(max_key_size+1-key.to_s.size)}: #{src_package[:url]}"
157
+ }
158
+ end
159
+
160
+ task :find_src do
161
+ # XXX ugly line - look away
162
+ max_key_size = SRC_PACKAGES.keys.max{|a,b| a.to_s.size <=> b.to_s.size}.to_s.size
163
+ SRC_PACKAGES.each{|key, src_package|
164
+ deprec2.set_package_defaults(src_package)
165
+ puts "#{key}#{' '*(max_key_size+1-key.to_s.size)}: #{src_package[:url]}"
166
+ puts `find . -name #{src_package[:filename]}`
167
+ puts
168
+ }
169
+ end
170
+
171
+ task :recover_src do
172
+ # XXX ugly line - look away
173
+ max_key_size = SRC_PACKAGES.keys.max{|a,b| a.to_s.size <=> b.to_s.size}.to_s.size
174
+ SRC_PACKAGES.each{|key, src_package|
175
+ puts "#{key}#{' '*(max_key_size+1-key.to_s.size)}: #{src_package[:url]}"
176
+ file = `find . -name #{src_package[:filename]}`.split[0]
177
+ `cp #{file} src/` if file
178
+ puts
179
+ }
180
+ end
181
+
182
+ end
183
+
184
+ end
@@ -0,0 +1,71 @@
1
+ # Copyright 2006-2008 by Mike Bailey. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+
4
+ # deprecated tasks from deprec1
5
+ # we're now using namespaces and some different naming conventions
6
+
7
+ # XXX use deprecated function to generate these dynamically
8
+
9
+ deprec2_isnt_backwards_compatible = <<-EOF
10
+
11
+ You've installed deprec2 but seem to be using a deprec1 command.
12
+
13
+ You have two options:
14
+
15
+ - install deprec-1.9.x and continue using deprec1
16
+
17
+ Instructions are available at http://www.deprec.org/
18
+
19
+ - use deprec2
20
+
21
+ EOF
22
+
23
+ cap2_warning = <<-EOF
24
+
25
+ You're using Capistrano 2 but using a deprecated cap1 command.
26
+
27
+ EOF
28
+
29
+ task :setup_admin_account do
30
+ puts deprec2_isnt_backwards_compatible
31
+ puts " Replace 'cap setup_admin_account' with 'cap deprec:users:add'"
32
+ puts
33
+ end
34
+
35
+ task :change_root_password do
36
+ puts deprec2_isnt_backwards_compatible
37
+ puts " Replace 'cap change_root_password' with 'cap deprec:users:passwd'"
38
+ puts
39
+ end
40
+
41
+ task :setup_ssh_keys do
42
+ puts deprec2_isnt_backwards_compatible
43
+ puts " Replace 'cap setup_ssh_keys' with 'cap deprec:ssh:setup_keys'"
44
+ puts
45
+ end
46
+
47
+ task :install_rails_stack do
48
+ puts deprec2_isnt_backwards_compatible
49
+ puts " Replace 'cap install_rails_stack' with 'cap deprec:rails:install_rails_stack'"
50
+ puts
51
+ end
52
+
53
+ task :setup do
54
+ puts deprec2_isnt_backwards_compatible
55
+ puts " Replace 'cap setup' with 'cap deploy:setup'"
56
+ puts
57
+ end
58
+
59
+ task :restart_apache do
60
+ puts deprec2_isnt_backwards_compatible
61
+ puts " Replace 'cap restart_apache' with 'cap deprec:apache:restart'"
62
+ puts
63
+ end
64
+
65
+ task :show_tasks do
66
+ puts deprec2_isnt_backwards_compatible
67
+ puts " Replace 'cap show-tasks' with 'cap -T'"
68
+ puts
69
+ end
70
+
71
+ end
@@ -1,5 +1,5 @@
1
1
  module Deprec
2
2
  module Core
3
- VERSION = "3.1.1"
3
+ VERSION = "3.1.2"
4
4
  end
5
5
  end
data/lib/deprec-core.rb CHANGED
@@ -3,12 +3,9 @@ require "deprec-core/version"
3
3
  if defined?(Capistrano)
4
4
  require "#{File.dirname(__FILE__)}/deprec-core/capistrano_extensions"
5
5
  require "#{File.dirname(__FILE__)}/vmbuilder_plugins/all"
6
+ require "#{File.dirname(__FILE__)}/deprec-core/canonical"
7
+ require "#{File.dirname(__FILE__)}/deprec-core/deprec"
8
+ require "#{File.dirname(__FILE__)}/deprec-core/deprecated"
6
9
  elsif defined?(rake)
7
10
  # pass
8
11
  end
9
-
10
- module Deprec
11
- module Core
12
- # Your code goes here...
13
- end
14
- end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: deprec-core
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 3.1.1
5
+ version: 3.1.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Mike Bailey
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-07-15 00:00:00 Z
13
+ date: 2011-07-16 00:00:00 Z
14
14
  dependencies: []
15
15
 
16
16
  description: deprec-core was extracted from the popular deprec gem to make it easier for people to publish Capistrano and Rake task gems
@@ -24,12 +24,16 @@ extra_rdoc_files: []
24
24
 
25
25
  files:
26
26
  - .gitignore
27
+ - CHANGELOG
27
28
  - Gemfile
28
29
  - README.md
29
30
  - Rakefile
30
31
  - deprec-core.gemspec
31
32
  - lib/deprec-core.rb
33
+ - lib/deprec-core/canonical.rb
32
34
  - lib/deprec-core/capistrano_extensions.rb
35
+ - lib/deprec-core/deprec.rb
36
+ - lib/deprec-core/deprecated.rb
33
37
  - lib/deprec-core/version.rb
34
38
  - lib/vmbuilder_plugins/all.rb
35
39
  - lib/vmbuilder_plugins/apt.rb