Permalink
Browse files

partial, cli working

  • Loading branch information...
Matt Conway
Matt Conway committed Sep 22, 2011
1 parent 042d19f commit fd8ee16b82f0cf0d172924aebfe9891df5c44872
Showing with 472 additions and 175 deletions.
  1. +1 −0 lib/rubber.rb
  2. +54 −125 lib/rubber/cli.rb
  3. +69 −0 lib/rubber/commands/config.rb
  4. +211 −0 lib/rubber/commands/util.rb
  5. +122 −0 lib/rubber/commands/vulcanize.rb
  6. +6 −3 lib/rubber/environment.rb
  7. +9 −1 lib/rubber/util.rb
  8. +0 −27 lib/templates/base/Rakefile
  9. +0 −15 lib/templates/base/lib/tasks/rubber.rake
  10. 0 {lib → }/templates/apache/config/rubber/deploy-apache.rb
  11. 0 {lib → }/templates/apache/config/rubber/role/apache/deflate.conf
  12. 0 {lib → }/templates/apache/config/rubber/role/apache/expires.conf
  13. 0 {lib → }/templates/apache/config/rubber/role/apache/headers.conf
  14. 0 {lib → }/templates/apache/config/rubber/role/apache/monit-apache.conf
  15. 0 {lib → }/templates/apache/config/rubber/role/apache/ports.conf
  16. 0 {lib → }/templates/apache/config/rubber/role/apache/setenvif.conf
  17. 0 {lib → }/templates/apache/config/rubber/role/web_tools/tools-apache-vhost.conf
  18. 0 {lib → }/templates/apache/config/rubber/role/web_tools/tools-apache.auth
  19. 0 {lib → }/templates/apache/config/rubber/role/web_tools/tools-index.html
  20. 0 {lib → }/templates/apache/config/rubber/rubber-apache.yml
  21. 0 {lib → }/templates/apache/templates.yml
  22. 0 {lib → }/templates/base/Capfile
  23. 0 {lib → }/templates/base/config/deploy.rb
  24. 0 {lib → }/templates/base/config/rubber/common/crontab
  25. 0 {lib → }/templates/base/config/rubber/common/monit-postfix.conf
  26. 0 {lib → }/templates/base/config/rubber/common/rubber.profile
  27. 0 {lib → }/templates/base/config/rubber/deploy-setup.rb
  28. 0 {lib → }/templates/base/config/rubber/deploy-util.rb
  29. 0 {lib → }/templates/base/config/rubber/rubber-dns.yml
  30. 0 {lib → }/templates/base/config/rubber/rubber-rvm.yml
  31. 0 {lib → }/templates/base/config/rubber/rubber.yml
  32. 0 {lib → }/templates/base/script/cron-rake
  33. 0 {lib → }/templates/base/script/cron-runner
  34. 0 {lib → }/templates/base/script/cron-sh
  35. +0 −4 {lib → }/templates/base/templates.rb
  36. 0 {lib → }/templates/base/templates.yml
  37. 0 {lib → }/templates/cassandra/config/rubber/deploy-cassandra.rb
  38. 0 {lib → }/templates/cassandra/config/rubber/role/cassandra/cassandra.in.sh
  39. 0 {lib → }/templates/cassandra/config/rubber/role/cassandra/cassandra.yaml
  40. 0 {lib → }/templates/cassandra/config/rubber/role/cassandra/log4j-server.properties
  41. 0 {lib → }/templates/cassandra/config/rubber/role/cassandra/monit-cassandra.conf
  42. 0 {lib → }/templates/cassandra/config/rubber/rubber-cassandra.yml
  43. 0 {lib → }/templates/cassandra/templates.yml
  44. 0 {lib → }/templates/complete_mongrel_mysql/config/rubber/role/haproxy/haproxy-mongrel.conf
  45. 0 {lib → }/templates/complete_mongrel_mysql/config/rubber/role/nginx/nginx-mongrel.conf
  46. 0 {lib → }/templates/complete_mongrel_mysql/config/rubber/rubber-complete.yml
  47. 0 {lib → }/templates/complete_mongrel_mysql/templates.yml
  48. 0 {lib → }/templates/complete_passenger/config/rubber/role/haproxy/haproxy-passenger.conf
  49. 0 {lib → }/templates/complete_passenger/config/rubber/rubber-complete.yml
  50. 0 {lib → }/templates/complete_passenger/templates.rb
  51. 0 {lib → }/templates/complete_passenger/templates.yml
  52. 0 {lib → }/templates/complete_passenger_mysql/templates.yml
  53. 0 {lib → }/templates/complete_passenger_postgresql/templates.yml
  54. 0 {lib → }/templates/cruise/config/rubber/deploy-cruise.rb
  55. 0 {lib → }/templates/cruise/config/rubber/role/cruise/cruise
  56. 0 {lib → }/templates/cruise/config/rubber/role/cruise/my.cnf
  57. 0 {lib → }/templates/cruise/config/rubber/role/cruise/production.rb
  58. 0 {lib → }/templates/cruise/config/rubber/role/cruise/site_config.rb
  59. 0 {lib → }/templates/cruise/config/rubber/role/web_tools/cruise-nginx.conf
  60. 0 {lib → }/templates/cruise/config/rubber/rubber-cruise.yml
  61. 0 {lib → }/templates/cruise/templates.yml
  62. 0 {lib → }/templates/haproxy/config/rubber/deploy-haproxy.rb
  63. 0 {lib → }/templates/haproxy/config/rubber/role/haproxy/haproxy-base.conf
  64. 0 {lib → }/templates/haproxy/config/rubber/role/haproxy/haproxy-default.conf
  65. 0 {lib → }/templates/haproxy/config/rubber/role/haproxy/monit-haproxy.conf
  66. 0 {lib → }/templates/haproxy/config/rubber/role/haproxy/syslog-haproxy.conf
  67. 0 {lib → }/templates/haproxy/config/rubber/role/haproxy/syslogd-default.conf
  68. 0 {lib → }/templates/haproxy/config/rubber/role/web_tools/haproxy-nginx.conf
  69. 0 {lib → }/templates/haproxy/config/rubber/rubber-haproxy.yml
  70. 0 {lib → }/templates/haproxy/templates.yml
  71. 0 {lib → }/templates/jetty/config/rubber/deploy-jetty.rb
  72. 0 {lib → }/templates/jetty/config/rubber/role/jetty/jetty.sh
  73. 0 {lib → }/templates/jetty/config/rubber/role/jetty/jetty.xml
  74. 0 {lib → }/templates/jetty/config/rubber/role/jetty/monit-jetty.conf
  75. 0 {lib → }/templates/jetty/config/rubber/rubber-jetty.yml
  76. 0 {lib → }/templates/jetty/templates.yml
  77. 0 {lib → }/templates/memcached/config/memcached.yml
  78. 0 {lib → }/templates/memcached/config/rubber/common/memcached.yml
  79. 0 {lib → }/templates/memcached/config/rubber/role/memcached/memcached.conf
  80. 0 {lib → }/templates/memcached/config/rubber/role/memcached/memcached_munin_plugin
  81. 0 {lib → }/templates/memcached/config/rubber/rubber-memcached.yml
  82. 0 {lib → }/templates/memcached/templates.yml
  83. 0 {lib → }/templates/minimal_mysql/templates.yml
  84. 0 {lib → }/templates/minimal_nodb/templates.yml
  85. 0 {lib → }/templates/mongodb/config/rubber/deploy-mongodb.rb
  86. 0 {lib → }/templates/mongodb/config/rubber/role/mongodb/mongodb.conf
  87. 0 {lib → }/templates/mongodb/config/rubber/role/mongodb/monit-mongodb.cnf
  88. 0 {lib → }/templates/mongodb/config/rubber/rubber-mongodb.yml
  89. 0 {lib → }/templates/mongodb/templates.yml
  90. 0 {lib → }/templates/mongrel/config/rubber/deploy-mongrel.rb
  91. 0 {lib → }/templates/mongrel/config/rubber/role/mongrel/mongrel_cluster.yml
  92. 0 {lib → }/templates/mongrel/config/rubber/role/mongrel/monit-mongrel.conf
  93. 0 {lib → }/templates/mongrel/config/rubber/rubber-mongrel.yml
  94. 0 {lib → }/templates/mongrel/templates.yml
  95. 0 {lib → }/templates/monit/config/rubber/common/monit-default.conf
  96. 0 {lib → }/templates/monit/config/rubber/common/monit.conf
  97. 0 {lib → }/templates/monit/config/rubber/deploy-monit.rb
  98. 0 {lib → }/templates/monit/config/rubber/role/web_tools/monit-admin-nginx.conf
  99. 0 {lib → }/templates/monit/config/rubber/rubber-monit.yml
  100. 0 {lib → }/templates/monit/templates.yml
  101. 0 {lib → }/templates/munin/config/rubber/common/monit-munin.conf
  102. 0 {lib → }/templates/munin/config/rubber/common/munin-node.conf
  103. 0 {lib → }/templates/munin/config/rubber/common/munin-plugins.conf
  104. 0 {lib → }/templates/munin/config/rubber/deploy-munin.rb
  105. 0 {lib → }/templates/munin/config/rubber/role/web_tools/munin-nginx.conf
  106. 0 {lib → }/templates/munin/config/rubber/role/web_tools/munin-plugins.conf
  107. 0 {lib → }/templates/munin/config/rubber/role/web_tools/munin.conf
  108. 0 {lib → }/templates/munin/config/rubber/rubber-munin.yml
  109. 0 {lib → }/templates/munin/script/munin/example_mysql_query.rb
  110. 0 {lib → }/templates/munin/script/munin/example_simple.rb
  111. 0 {lib → }/templates/munin/templates.yml
  112. 0 {lib → }/templates/mysql/config/rubber/common/database.yml
  113. 0 {lib → }/templates/mysql/config/rubber/deploy-mysql.rb
  114. 0 {lib → }/templates/mysql/config/rubber/role/db/apparmor-mysql.conf
  115. 0 {lib → }/templates/mysql/config/rubber/role/db/crontab
  116. 0 {lib → }/templates/mysql/config/rubber/role/db/monit-mysql.cnf
  117. 0 {lib → }/templates/mysql/config/rubber/role/db/my.cnf
  118. 0 {lib → }/templates/mysql/config/rubber/role/mysql_slave/mysql_slave_munin_plugin
  119. 0 {lib → }/templates/mysql/config/rubber/rubber-mysql.yml
  120. 0 {lib → }/templates/mysql/templates.yml
  121. 0 {lib → }/templates/mysql_cluster/config/rubber/common/mysql_cluster_migrations.rb
  122. 0 {lib → }/templates/mysql_cluster/config/rubber/deploy-mysql_cluster.rb
  123. 0 {lib → }/templates/mysql_cluster/config/rubber/role/mysql_data/my.cnf
  124. 0 {lib → }/templates/mysql_cluster/config/rubber/role/mysql_mgm/ndb_mgmd.cnf
  125. 0 {lib → }/templates/mysql_cluster/config/rubber/role/mysql_sql/monit-mysql_cluster_sql.cnf
  126. 0 {lib → }/templates/mysql_cluster/config/rubber/role/mysql_sql/my.cnf
  127. 0 {lib → }/templates/mysql_cluster/config/rubber/rubber-mysql_cluster.yml
  128. 0 {lib → }/templates/mysql_cluster/templates.yml
  129. 0 {lib → }/templates/mysql_proxy/config/rubber/common/database.yml
  130. 0 {lib → }/templates/mysql_proxy/config/rubber/common/monit-mysql_proxy.cnf
  131. 0 {lib → }/templates/mysql_proxy/config/rubber/common/mysql-proxy
  132. 0 {lib → }/templates/mysql_proxy/config/rubber/common/mysql-proxy.conf
  133. 0 {lib → }/templates/mysql_proxy/config/rubber/common/mysql-proxy.lua
  134. 0 {lib → }/templates/mysql_proxy/config/rubber/deploy-mysql_proxy.rb
  135. 0 {lib → }/templates/mysql_proxy/config/rubber/rubber-mysql_proxy.yml
  136. 0 {lib → }/templates/mysql_proxy/templates.yml
  137. 0 {lib → }/templates/nginx/config/rubber/deploy-nginx.rb
  138. 0 {lib → }/templates/nginx/config/rubber/role/nginx/crontab
  139. 0 {lib → }/templates/nginx/config/rubber/role/nginx/monit-nginx.conf
  140. 0 {lib → }/templates/nginx/config/rubber/role/nginx/nginx.conf
  141. 0 {lib → }/templates/nginx/config/rubber/role/web_tools/nginx-tools.conf
  142. 0 {lib → }/templates/nginx/config/rubber/role/web_tools/tools-index.html
  143. 0 {lib → }/templates/nginx/config/rubber/role/web_tools/tools-nginx.auth
  144. 0 {lib → }/templates/nginx/config/rubber/rubber-nginx.yml
  145. 0 {lib → }/templates/nginx/templates.yml
  146. 0 {lib → }/templates/passenger/config/rubber/deploy-passenger.rb
  147. 0 {lib → }/templates/passenger/config/rubber/role/passenger/munin-passenger-memory.conf
  148. 0 {lib → }/templates/passenger/config/rubber/role/passenger/munin-passenger-sudoers.conf
  149. 0 {lib → }/templates/passenger/config/rubber/role/passenger/munin-passenger.conf
  150. 0 {lib → }/templates/passenger/config/rubber/role/passenger/passenger-apache-vhost.conf
  151. 0 {lib → }/templates/passenger/config/rubber/role/passenger/passenger.conf
  152. 0 {lib → }/templates/passenger/config/rubber/rubber-passenger.yml
  153. 0 {lib → }/templates/passenger/templates.yml
  154. 0 {lib → }/templates/postgresql/config/rubber/common/database.yml
  155. 0 {lib → }/templates/postgresql/config/rubber/deploy-postgresql.rb
  156. 0 {lib → }/templates/postgresql/config/rubber/role/db/crontab
  157. 0 {lib → }/templates/postgresql/config/rubber/role/db/monit-postgresql.conf
  158. 0 {lib → }/templates/postgresql/config/rubber/role/db/munin-postgresql.conf
  159. 0 {lib → }/templates/postgresql/config/rubber/role/db/pg_hba.conf
  160. 0 {lib → }/templates/postgresql/config/rubber/role/db/postgresql-sysctl.conf
  161. 0 {lib → }/templates/postgresql/config/rubber/role/db/postgresql.conf
  162. 0 {lib → }/templates/postgresql/config/rubber/rubber-postgresql.yml
  163. 0 {lib → }/templates/postgresql/templates.yml
  164. 0 {lib → }/templates/redis/config/rubber/deploy-redis.rb
  165. 0 {lib → }/templates/redis/config/rubber/role/redis/crontab
  166. 0 {lib → }/templates/redis/config/rubber/role/redis/monit-redis.conf
  167. 0 {lib → }/templates/redis/config/rubber/role/redis/redis-sysctl.conf
  168. 0 {lib → }/templates/redis/config/rubber/role/redis/redis.conf
  169. 0 {lib → }/templates/redis/config/rubber/rubber-redis.yml
  170. 0 {lib → }/templates/redis/templates.yml
  171. 0 {lib → }/templates/resque/config/initializers/resque.rb
  172. 0 {lib → }/templates/resque/config/rubber/common/resque.yml
  173. 0 {lib → }/templates/resque/config/rubber/deploy-resque.rb
  174. 0 {lib → }/templates/resque/config/rubber/role/resque_web/monit-resque_web.conf
  175. 0 {lib → }/templates/resque/config/rubber/role/resque_worker/monit-resque_worker.conf
  176. 0 {lib → }/templates/resque/config/rubber/rubber-resque.yml
  177. 0 {lib → }/templates/resque/script/resque_worker_management.rb
  178. 0 {lib → }/templates/resque/templates.rb
  179. 0 {lib → }/templates/resque/templates.yml
  180. 0 {lib → }/templates/sphinx/config/rubber/common/sphinx.yml
  181. 0 {lib → }/templates/sphinx/config/rubber/deploy-sphinx.rb
  182. 0 {lib → }/templates/sphinx/config/rubber/role/sphinx/crontab
  183. 0 {lib → }/templates/sphinx/config/rubber/role/sphinx/monit-sphinx.conf
  184. 0 {lib → }/templates/sphinx/config/rubber/rubber-sphinx.yml
  185. 0 {lib → }/templates/sphinx/templates.yml
View
@@ -59,6 +59,7 @@ def self.instances
end
+require 'rubber/version'
require 'rubber/thread_safe_proxy'
require 'rubber/configuration'
require 'rubber/environment'
View
@@ -1,161 +1,90 @@
require "thor"
+require "thor/group"
+require "thor/runner"
module Rubber
class CLI < Thor
- include Thor::Actions
-
- def self.source_root
- File.expand_path(File.join(File.dirname(__FILE__), '..', 'templates'))
- end
-
- desc "config", "Generate system config files by transforming the files in the config/rubber tree"
- method_options :host => :string, :roles => :string, :file => :string,
- :no_post => :boolean, :force => :boolean
-
- def config
- cfg = Rubber::Configuration.get_configuration(Rubber.env)
- instance_alias = cfg.environment.current_host
- instance = cfg.instance[instance_alias]
- if instance
- roles = instance.role_names
- env = cfg.environment.bind(roles, instance_alias)
- gen = Rubber::Configuration::Generator.new("#{Rubber.root}/config/rubber", roles, instance_alias)
- elsif ['development', 'test'].include?(Rubber.env)
- instance_alias = options[:host] || instance_alias
- roles = options[:roles].split(',') if options[:roles]
- roles ||= cfg.environment.known_roles
- role_items = roles.collect do |r|
- Rubber::Configuration::RoleItem.new(r, r == "db" ? {'primary' => true} : {})
- end
- env = cfg.environment.bind(roles, instance_alias)
- domain = env.domain
- instance = Rubber::Configuration::InstanceItem.new(instance_alias, domain, role_items,
- 'dummyid', 'm1.small', 'ami-7000f019', ['dummygroup'])
- instance.external_host = instance.full_name
- instance.external_ip = "127.0.0.1"
- instance.internal_host = instance.full_name
- instance.internal_ip = "127.0.0.1"
- cfg.instance.add(instance)
- gen = Rubber::Configuration::Generator.new("#{Rubber.root}/config/rubber", roles, instance_alias)
- gen.fake_root ="#{Rubber.root}/tmp/rubber"
+ # Override Thor#help so it can give information about any class and any method.
+ #
+ def help(meth = nil)
+ initialize_thorfiles
+ if meth && !self.respond_to?(meth)
+ klass, task = find_class_and_task_by_namespace(meth)
+ klass.start(["-h", task].compact, :shell => self.shell)
else
- puts "Instance not found for host: #{instance_alias}"
- exit 1
+ display_klasses
end
+ end
- if options[:file]
- gen.file_pattern = options[:file]
- end
- gen.no_post = options[:no_post]
- gen.force = options[:force]
- gen.stop_on_error_cmd = env.stop_on_error_cmd
- gen.run
+ # If a task is not found on Thor::Runner, method missing is invoked and
+ # Thor::Runner is then responsable for finding the task in all classes.
+ #
+ def method_missing(meth, *args)
+ initialize_thorfiles
- end
+ klass, task = find_class_and_task_by_namespace(meth)
- def self.valid_templates()
- valid = Dir.entries(self.source_root).delete_if {|e| e =~ /(^\.)|svn|CVS/ }
+ args.unshift(task) if task
+ klass.start(args, :shell => self.shell)
end
- desc "vulcanize TEMPLATE", <<-EOS
- Prepares the rails application for deploying with rubber by installing
- a sample rubber configuration template.
+ private
- e.g. rubber vulcanize complete_passenger_postgresql
+ def find_class_and_task_by_namespace(meth)
+ meth = meth.to_s
- where TEMPLATE is one of:
- #{valid_templates.join(", ")}
- EOS
+ pieces = meth.split(":")
+ task = pieces.pop
+ namespace = pieces.join(":")
+ namespace = "default#{namespace}" if namespace.empty? || namespace =~ /^:/
- def vulcanize(template_name)
- @template_dependencies = find_dependencies(template_name)
- ([template_name] + @template_dependencies).each do |template|
- apply_template(template)
- end
+ klass = Thor::Base.subclasses.find { |k| k.namespace == namespace && k.tasks[task] }
+ return klass, task
end
- protected
-
- # helper to test for rails for optional templates
- def rails?
- Rubber::Util::is_rails?
+ def self.exit_on_failure?
+ true
end
- def find_dependencies(name)
- template_dir = File.join(self.class.source_root, name, '')
- unless File.directory?(template_dir)
- raise Thor::Error.new("Invalid template #{name}, use one of #{valid_templates.join(', ')}")
- end
-
- template_conf = load_template_config(template_dir)
- template_dependencies = template_conf['dependent_templates'] || []
-
- template_dependencies.clone.each do |dep|
- template_dependencies.concat(find_dependencies(dep))
+ def initialize_thorfiles
+ files = Dir[File.expand_path(File.join(File.dirname(__FILE__), 'commands/*.rb'))]
+ files.each do |f|
+ require f
end
-
- return template_dependencies.uniq
end
- def apply_template(name)
- template_dir = File.join(self.class.source_root, name, '')
- unless File.directory?(template_dir)
- raise Thor::Error.new("Invalid template #{name}, use one of #{valid_templates.join(', ')}")
- end
-
- template_conf = load_template_config(template_dir)
-
- extra_generator_steps_file = File.join(template_dir, 'templates.rb')
+ def display_klasses(show_internal=false, klasses=Thor::Base.subclasses)
+ klasses -= [Thor, Thor::Runner, Thor::Group] unless show_internal
- Find.find(template_dir) do |f|
- Find.prune if f == File.join(template_dir, 'templates.yml') # don't copy over templates.yml
- Find.prune if f == extra_generator_steps_file # don't copy over templates.rb
+ raise Error, "No Thor tasks available" if klasses.empty?
- template_rel = f.gsub(/#{template_dir}/, '')
- source_rel = f.gsub(/#{self.class.source_root}\//, '')
- dest_rel = source_rel.gsub(/^#{name}\//, '')
-
- # Only include optional files when their conditions eval to true
- optional = template_conf['optional'][template_rel] rescue nil
- Find.prune if optional && ! eval(optional)
-
- if File.directory?(f)
- empty_directory(dest_rel)
- else
- copy_file(source_rel, dest_rel)
- src_mode = File.stat(f).mode
- dest_mode = File.stat(File.join(destination_root, dest_rel)).mode
- chmod(dest_rel, src_mode) if src_mode != dest_mode
- end
- end
+ list = Hash.new { |h,k| h[k] = [] }
+ groups = klasses.select { |k| k.ancestors.include?(Thor::Group) }
- if File.exist? extra_generator_steps_file
- eval File.read(extra_generator_steps_file), binding, extra_generator_steps_file
- end
- end
+ # Get classes which inherit from Thor
+ (klasses - groups).each { |k| list[k.namespace.split(":").first] += k.printable_tasks(false) }
- def load_template_config(template_dir)
- YAML.load(File.read(File.join(template_dir, 'templates.yml'))) rescue {}
- end
+ # Get classes which inherit from Thor::Base
+ groups.map! { |k| k.printable_tasks(false).first }
+ list["root"] = groups
- def rubber_env()
- Rubber::Configuration.rubber_env
+ # Order namespaces with default coming first
+ list = list.sort{ |a,b| a[0].sub(/^default/, '') <=> b[0].sub(/^default/, '') }
+ list.each { |n, tasks| display_tasks(n, tasks) unless tasks.empty? }
end
- def rubber_instances()
- Rubber::Configuration.rubber_instances
- end
+ def display_tasks(namespace, list) #:nodoc:
+ list.sort!{ |a,b| a[0] <=> b[0] }
- def cloud_provider
- rubber_env.cloud_providers[rubber_env.cloud_provider]
- end
+ say shell.set_color(namespace, :blue, true)
+ say "-" * namespace.size
- def init_s3()
- AWS::S3::Base.establish_connection!(:access_key_id => cloud_provider.access_key, :secret_access_key => cloud_provider.secret_access_key)
+ print_table(list, :truncate => true)
+ say
end
end
-
+
end
@@ -0,0 +1,69 @@
+
+module Rubber
+ module Commands
+
+ class Config < Thor
+
+ namespace :default
+
+ method_option :host, :type => :string, :aliases => "-h",
+ :desc => "Override the instance's host for generation"
+ method_option :roles, :type => :string, :aliases => "-r",
+ :desc => "Override the instance's roles for generation"
+ method_option :file, :type => :boolean, :aliases => "-p",
+ :desc => "Only generate files that match the given pattern"
+ method_option :no_post, :type => :boolean, :aliases => "-n",
+ :desc => "Skip running post commands for files that get generated"
+ method_option :force, :type => :boolean, :aliases => "-f",
+ :desc => "Overwrite files that already exist"
+
+ desc "config", Rubber::Util.clean_indent(<<-EOS
+ Generate system config files by transforming the files in the config/rubber tree
+ EOS
+ )
+
+ def config
+ cfg = Rubber::Configuration.get_configuration(Rubber.env)
+ instance_alias = cfg.environment.current_host
+ instance = cfg.instance[instance_alias]
+ if instance
+ roles = instance.role_names
+ env = cfg.environment.bind(roles, instance_alias)
+ gen = Rubber::Configuration::Generator.new("#{Rubber.root}/config/rubber", roles, instance_alias)
+ elsif ['development', 'test'].include?(Rubber.env)
+ instance_alias = options[:host] || instance_alias
+ roles = options[:roles].split(',') if options[:roles]
+ roles ||= cfg.environment.known_roles
+ role_items = roles.collect do |r|
+ Rubber::Configuration::RoleItem.new(r, r == "db" ? {'primary' => true} : {})
+ end
+ env = cfg.environment.bind(roles, instance_alias)
+ domain = env.domain
+ instance = Rubber::Configuration::InstanceItem.new(instance_alias, domain, role_items,
+ 'dummyid', 'm1.small', 'ami-7000f019', ['dummygroup'])
+ instance.external_host = instance.full_name
+ instance.external_ip = "127.0.0.1"
+ instance.internal_host = instance.full_name
+ instance.internal_ip = "127.0.0.1"
+ cfg.instance.add(instance)
+ gen = Rubber::Configuration::Generator.new("#{Rubber.root}/config/rubber", roles, instance_alias)
+ gen.fake_root ="#{Rubber.root}/tmp/rubber"
+ else
+ puts "Instance not found for host: #{instance_alias}"
+ exit 1
+ end
+
+ if options[:file]
+ gen.file_pattern = options[:file]
+ end
+ gen.no_post = options[:no_post]
+ gen.force = options[:force]
+ gen.stop_on_error_cmd = env.stop_on_error_cmd
+ gen.run
+
+ end
+
+ end
+
+ end
+end
Oops, something went wrong.

0 comments on commit fd8ee16

Please sign in to comment.