rubber 2.0.5 → 2.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/.travis.yml +2 -2
  2. data/CHANGELOG +50 -0
  3. data/lib/rubber/commands/cron.rb +9 -11
  4. data/lib/rubber/commands/util.rb +1 -0
  5. data/lib/rubber/dns.rb +29 -4
  6. data/lib/rubber/dns/aws.rb +181 -0
  7. data/lib/rubber/dns/nettica.rb +74 -36
  8. data/lib/rubber/dns/zerigo.rb +110 -4
  9. data/lib/rubber/instance.rb +1 -1
  10. data/lib/rubber/recipes/rubber/instances.rb +13 -5
  11. data/lib/rubber/recipes/rubber/security_groups.rb +1 -1
  12. data/lib/rubber/recipes/rubber/setup.rb +80 -64
  13. data/lib/rubber/util.rb +7 -0
  14. data/lib/rubber/version.rb +1 -1
  15. data/templates/base/config/rubber/deploy-setup.rb +12 -0
  16. data/templates/base/config/rubber/rubber-dns.yml +17 -21
  17. data/templates/base/config/rubber/rubber.yml +2 -2
  18. data/templates/collectd/config/rubber/role/passenger/passenger-status-sudoers.conf +1 -1
  19. data/templates/elasticsearch/config/rubber/rubber-elasticsearch.yml +1 -1
  20. data/templates/graphite/config/rubber/role/graphite_web/dashboard.html +5 -3
  21. data/templates/jenkins/config/environments/jenkins.rb +1 -1
  22. data/templates/jenkins/config/rubber/rubber-jenkins.yml +1 -1
  23. data/templates/passenger/config/rubber/deploy-passenger.rb +0 -8
  24. data/templates/postgresql/config/rubber/rubber-postgresql.yml +2 -2
  25. data/templates/resque/config/initializers/resque.rb +2 -2
  26. data/templates/resque/config/resque.yml +4 -0
  27. data/templates/resque/config/rubber/common/resque.yml +1 -1
  28. data/templates/resque_scheduler/config/rubber/common/resque_schedule.yml +9 -0
  29. data/templates/resque_scheduler/config/rubber/deploy-resque_scheduler.rb +38 -0
  30. data/templates/resque_scheduler/config/rubber/role/resque_scheduler/resque-scheduler-upstart.conf +20 -0
  31. data/templates/resque_scheduler/config/rubber/rubber-resque_scheduler.yml +7 -0
  32. data/templates/resque_scheduler/lib/tasks/resque-scheduler.rake +28 -0
  33. data/templates/resque_scheduler/templates.rb +1 -0
  34. data/templates/resque_scheduler/templates.yml +3 -0
  35. data/templates/torquebox/config/rubber/rubber-torquebox.yml +1 -1
  36. data/templates/zookeeper/config/rubber/role/zookeeper/myid.conf +5 -4
  37. data/templates/zookeeper/config/rubber/role/zookeeper/zoo.cfg +6 -1
  38. data/test/command_test.rb +0 -55
  39. data/test/commands/cron_test.rb +83 -0
  40. data/test/dns/aws_test.rb +192 -0
  41. data/test/dns/zerigo_test.rb +180 -0
  42. data/test/instance_test.rb +17 -2
  43. data/test/test_helper.rb +37 -2
  44. metadata +20 -8
  45. data/lib/rubber/dns/fog.rb +0 -219
  46. data/test/dns/fog_test.rb +0 -169
@@ -75,11 +75,11 @@ cloud_providers:
75
75
 
76
76
  # REQUIRED: the ami and instance type for creating instances
77
77
  # The Ubuntu images at http://alestic.com/ work well
78
- # Ubuntu 12.04 Precise instance-store 64-bit: ami-3c994355
78
+ # Ubuntu 12.04 Precise instance-store 64-bit: ami-eafa5883
79
79
  #
80
80
  # m1.small or m1.large or m1.xlarge
81
81
  image_type: m1.small
82
- image_id: ami-3c994355
82
+ image_id: ami-eafa5883
83
83
 
84
84
  # OPTIONAL: EC2 spot instance request support.
85
85
  #
@@ -2,7 +2,7 @@
2
2
  @path = '/etc/sudoers'
3
3
  @additive = ["# passenger-status start", "# passenger-status end"]
4
4
  %>
5
- Defaults env_keep = GEM_PATH
5
+ Defaults env_keep += GEM_PATH
6
6
 
7
7
  nobody ALL=(ALL) NOPASSWD: <%= rubber_env.rvm_gem_home %>/bin/passenger-status
8
8
  nobody ALL=(ALL) NOPASSWD: <%= rubber_env.rvm_gem_home %>/bin/passenger-memory-stats
@@ -9,7 +9,7 @@ elasticsearch_http_port: 9200
9
9
 
10
10
  roles:
11
11
  elasticsearch:
12
- packages: [openjdk-7-jdk]
12
+ packages: [openjdk-7-jdk, unzip]
13
13
 
14
14
  web_tools_proxies:
15
15
  elasticsearch:
@@ -212,10 +212,12 @@ Simple graphite dashboard cycler for use on a large display - e.g. googletv/chro
212
212
  var defn = e[1];
213
213
  var params = $.extend(true, {}, defaultParams); // deep copy
214
214
  params = $.extend(true, params, defn); // deep copy
215
- params["target"] = params["target"][0];
216
-
217
- var url = ROOT_URL + "/render?" + $.param(params);
218
215
 
216
+ // graphite only works with target=abc&target=xyz not with
217
+ // standard form of target[]=abc&target[]=xyz
218
+ var encoded_params = $.param(params).replace(/target%5B%5D=/g, "target=");
219
+ var url = ROOT_URL + "/render?" + encoded_params;
220
+
219
221
  return url;
220
222
  });
221
223
  return urls;
@@ -1,4 +1,4 @@
1
- Appleton::Application.configure do
1
+ Rails.application.class.configure do
2
2
  # Settings specified here will take precedence over those in config/application.rb
3
3
 
4
4
  # In the development environment your application's code is reloaded on
@@ -30,4 +30,4 @@ security_groups:
30
30
  roles:
31
31
  jenkins:
32
32
  assigned_security_groups: [jenkins_web]
33
- packages: [sun-java6-jdk, jenkins]
33
+ packages: [openjdk-6-jdk, jenkins]
@@ -21,14 +21,6 @@ namespace :rubber do
21
21
  ENDSCRIPT
22
22
  end
23
23
 
24
- # passenger does things differently for rack apps, so if this is a rails app, remove config.ru
25
- # to stop passenger from treating this like a rack app
26
- after "deploy:update_code", "rubber:passenger:remove_config_ru" if Rubber::Util.is_rails?
27
-
28
- task :remove_config_ru, :roles => :passenger do
29
- rsudo "rm -f #{releases_path}/*/config.ru"
30
- end
31
-
32
24
  # passenger depends on apache for start/stop/restart, just need these defined
33
25
  # as apache hooks into standard deploy lifecycle
34
26
 
@@ -1,8 +1,8 @@
1
1
  # REQUIRED: The credentials for creating/accessing your app's database
2
2
  #
3
- db_user: "#{app_name[0,16]}"
3
+ db_user: "#{app_name[0,16].downcase}"
4
4
  db_pass:
5
- db_name: "#{app_name}_#{Rubber.env}"
5
+ db_name: "#{app_name.downcase}_#{Rubber.env}"
6
6
 
7
7
  db_replication_user: replication
8
8
  db_replication_pass:
@@ -1,10 +1,10 @@
1
1
 
2
2
  redis_host = 'localhost:6379'
3
3
 
4
- resque_yml = Rubber.root + '/config/resque.yml'
4
+ resque_yml = Rubber.root.to_s + '/config/resque.yml'
5
5
  if File.exist? resque_yml
6
6
  resque_config = YAML.load_file(resque_yml)
7
- redis_host = resque_config[rails_env]
7
+ redis_host = resque_config[Rubber.env]
8
8
  end
9
9
 
10
10
  Resque.redis = redis_host
@@ -0,0 +1,4 @@
1
+ # this is a placeholder for development. for the production version, see config/rubber/common/resque.yml
2
+ environments:
3
+ development: 'localhost:6379'
4
+ test: 'localhost:6379'
@@ -2,4 +2,4 @@
2
2
  @path = "#{Rubber.root}/config/resque.yml"
3
3
  %>
4
4
 
5
- <%= Rubber.env %>: <%= rubber_instances.for_role('redis').first.full_name rescue 'localhost' %>:6379
5
+ <%= Rubber.env %>: <%= rubber_instances.for_role('redis_master').first.full_name rescue 'localhost' %>:6379
@@ -0,0 +1,9 @@
1
+ <%
2
+ @path = "#{Rubber.root}/config/resque_schedule.yml"
3
+ %>
4
+
5
+ myjob:
6
+ cron: 0 * * * *
7
+ class: MyJob
8
+ queue: scheduler
9
+ description: Schedules MyJob. Runs every hour on the hour.
@@ -0,0 +1,38 @@
1
+ namespace :rubber do
2
+
3
+ namespace :resque_scheduler do
4
+
5
+ rubber.allow_optional_tasks(self)
6
+
7
+ before "deploy:stop", "rubber:resque_scheduler:stop"
8
+ after "deploy:start", "rubber:resque_scheduler:start"
9
+ after "deploy:restart", "rubber:resque_scheduler:restart"
10
+
11
+ desc "Stops the resque_scheduler"
12
+ task :stop, :roles => :resque_scheduler do
13
+ rsudo "service resque-scheduler stop || true"
14
+ end
15
+
16
+ desc "Starts the resque_scheduler"
17
+ task :start, :roles => :resque_scheduler do
18
+ rsudo "service resque-scheduler start"
19
+ end
20
+
21
+ desc "Restarts the resque_scheduler"
22
+ task :restart, :roles => :resque_scheduler do
23
+ stop
24
+ start
25
+ end
26
+
27
+ # pauses deploy until daemon is up so monit doesn't try and start it
28
+ before "rubber:monit:start", "rubber:resque_scheduler:wait_start"
29
+ task :wait_start, :roles => :resque_scheduler do
30
+ logger.info "Waiting for scheduler daemon pid file to show up"
31
+
32
+ run "while ! test -f #{rubber_env.resque_scheduler_pid_file}; do sleep 1; done"
33
+ end
34
+
35
+
36
+ end
37
+
38
+ end
@@ -0,0 +1,20 @@
1
+ <%
2
+ @path = "/etc/init/resque-scheduler.conf"
3
+ @backup = false
4
+ %>
5
+ description "resque scheduler daemon"
6
+
7
+ start on runlevel [2345]
8
+ stop on runlevel [016]
9
+
10
+ script
11
+ exec sudo -u <%= rubber_env.app_user %> /bin/bash -l -c 'cd <%= Rubber.root %> && exec bundle exec rake resque:scheduler >> log/resque-scheduler_upstart.log 2>&1'
12
+ end script
13
+
14
+ post-start script
15
+ status resque-scheduler | head -n1 | awk '{print $NF}' > <%= rubber_env.resque_scheduler_pid_file %>
16
+ end script
17
+
18
+ post-stop script
19
+ rm -f <%= rubber_env.resque_scheduler_pid_file %>
20
+ end script
@@ -0,0 +1,7 @@
1
+ resque_scheduler_pid_file: /var/run/resque-scheduler.pid
2
+ resque_scheduler_log_file: /var/log/resque-scheduler.log
3
+
4
+ gems: [resque-scheduler]
5
+
6
+ role_dependencies:
7
+ web_tools: [resque_scheduler]
@@ -0,0 +1,28 @@
1
+ # Resque tasks
2
+ require 'resque/tasks'
3
+ require 'resque_scheduler/tasks'
4
+
5
+ namespace :resque do
6
+
7
+ task :setup do
8
+ # If you want to be able to dynamically change the schedule,
9
+ # uncomment this line. A dynamic schedule can be updated via the
10
+ # Resque::Scheduler.set_schedule (and remove_schedule) methods.
11
+ # When dynamic is set to true, the scheduler process looks for
12
+ # schedule changes and applies them on the fly.
13
+ # Note: This feature is only available in >=2.0.0.
14
+ #Resque::Scheduler.dynamic = true
15
+
16
+ # The schedule doesn't need to be stored in a YAML, it just needs to
17
+ # be a hash. YAML is usually the easiest.
18
+ # Resque.schedule = YAML.load_file('your_resque_schedule.yml')
19
+
20
+ # If your schedule already has +queue+ set for each job, you don't
21
+ # need to require your jobs. This can be an advantage since it's
22
+ # less code that resque-scheduler needs to know about. But in a small
23
+ # project, it's usually easier to just include you job classes here.
24
+ # So, something like this:
25
+ # require 'jobs'
26
+ end
27
+
28
+ end
@@ -0,0 +1 @@
1
+ append_to_file 'Gemfile', "gem 'resque-scheduler', :require => ['resque_scheduler', 'resque_scheduler/server']\n" if Rubber::Util::is_bundler?
@@ -0,0 +1,3 @@
1
+ description: The resque-scheduler job scheduler for resque
2
+ dependent_templates:
3
+ - resque
@@ -13,4 +13,4 @@ mod_cluster_version: 1.2.0
13
13
 
14
14
  roles:
15
15
  torquebox:
16
- packages: [openjdk-7-jdk libaio1]
16
+ packages: [openjdk-7-jdk, libaio1, unzip]
@@ -1,4 +1,5 @@
1
- <%
2
- @path = "#{rubber_env.zookeeper_install_dir}/conf/myid"
3
- %>
4
- <%= rubber_env.host.gsub(/[^0-9]*/, '').to_i %>
1
+ <%-
2
+ @path = "#{rubber_env.zookeeper_data_dir}/myid"
3
+ require 'zlib'
4
+ -%>
5
+ <%= Zlib.crc32(rubber_env.host) %>
@@ -1,7 +1,10 @@
1
1
  <%
2
2
  @path = "#{rubber_env.zookeeper_install_dir}/conf/zoo.cfg"
3
3
  @post = "mkdir -p #{rubber_env.zookeeper_data_dir}"
4
+ require 'zlib'
4
5
  %>
6
+ # Docs at http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_advancedConfiguration
7
+
5
8
  # The number of milliseconds of each tick
6
9
  tickTime=2000
7
10
  # The number of ticks that the initial
@@ -14,13 +17,15 @@ syncLimit=5
14
17
  dataDir=<%= rubber_env.zookeeper_data_dir %>
15
18
  # the port at which the clients will connect
16
19
  clientPort=<%= rubber_env.zookeeper_client_port %>
20
+ # limit to # of connections from a client (IP), default 10, 0 for unlimited
21
+ maxClientCnxns=0
17
22
 
18
23
  <%
19
24
  zookeeper_hosts = rubber_instances.for_role("zookeeper")
20
25
  if zookeeper_hosts.size > 1
21
26
  zookeeper_hosts.each do |ic|
22
27
  %>
23
- server.<%= ic.name.gsub(/[^0-9]*/, '').to_i %>=<%= ic.name %>:2888:3888
28
+ server.<%= Zlib.crc32(ic.name) %>=<%= ic.name %>:2888:3888
24
29
  <%
25
30
  end
26
31
  end
data/test/command_test.rb CHANGED
@@ -3,14 +3,9 @@ require File.expand_path(File.join(__FILE__, '..', 'test_helper'))
3
3
  class CommandTest < Test::Unit::TestCase
4
4
 
5
5
  def setup
6
- system("rm -f #{Rubber.root}/log/*.log")
7
6
  ENV['RUBBER_ROOT'] = Rubber.root
8
7
  end
9
8
 
10
- def teardown
11
- system("rm -f #{Rubber.root}/log/*.log")
12
- end
13
-
14
9
  def test_rubber_help
15
10
  out = `rubber`
16
11
  assert out =~ /Subcommands:\n(.*)\nOptions:/m
@@ -31,55 +26,5 @@ class CommandTest < Test::Unit::TestCase
31
26
  end
32
27
 
33
28
  end
34
-
35
- def test_rubber_cron_basic
36
- date = Time.now.tv_sec.to_s
37
- out = `rubber cron echo #{date}`
38
-
39
- assert_equal 0, $?
40
- assert_equal "", out
41
-
42
- logs = Dir["#{Rubber.root}/log/*.log"]
43
- assert_equal 1, logs.size
44
- assert_equal date, File.read(logs.first).strip
45
- end
46
-
47
- def test_rubber_cron_logfile
48
- date = Time.now.tv_sec.to_s
49
- out = `rubber cron -l #{Rubber.root}/log/foo.log -- echo #{date}`
50
- logs = Dir["#{Rubber.root}/log/*.log"]
51
- assert_equal 1, logs.size
52
- assert_equal "#{Rubber.root}/log/foo.log", logs.first
53
- assert_equal date, File.read(logs.first).strip
54
- end
55
-
56
- def test_rubber_cron_task_logfile
57
- date = Time.now.tv_sec.to_s
58
- out = `rubber cron --task -- cron -o -- echo #{date}`
59
- logs = Dir["#{Rubber.root}/log/cron-task*.log"]
60
- assert_equal 1, logs.size
61
- assert_equal date, File.read(logs.first).strip
62
- end
63
-
64
- def test_rubber_cron_directory_changed
65
- out = `rubber cron -o -r /tmp -- pwd`
66
- assert_match /(\/private)?\/tmp/, out, "Unexpected output:\n#{out}"
67
- end
68
-
69
- def test_rubber_cron_output_empty
70
- out = `rubber cron -- ls -la`
71
- assert_equal "", out, "Unexpected output:\n#{out}"
72
- end
73
-
74
- def test_rubber_cron_output_echoed
75
- out = `rubber cron -o -- ls -la`
76
- assert_not_equal "", out, "Unexpected output:\n#{out}"
77
- end
78
-
79
- def test_rubber_cron_output_on_error
80
- out = `rubber cron -- ls -la jkbhbj`
81
- assert_not_equal 0, $?
82
- assert_not_equal "", out, "Unexpected output:\n#{out}"
83
- end
84
29
 
85
30
  end
@@ -0,0 +1,83 @@
1
+ require File.expand_path(File.join(__FILE__, '../..', 'test_helper'))
2
+
3
+ class CronTest < Test::Unit::TestCase
4
+
5
+ def setup
6
+ system("rm -f #{Rubber.root}/log/*.log")
7
+ ENV['RUBBER_ROOT'] = Rubber.root
8
+ end
9
+
10
+ def teardown
11
+ system("rm -f #{Rubber.root}/log/*.log")
12
+ end
13
+
14
+ def test_rubber_cron_basic
15
+ date = Time.now.tv_sec.to_s
16
+ out = `rubber cron echo #{date}`
17
+
18
+ assert_equal 0, $?
19
+ assert_equal "", out
20
+
21
+ logs = Dir["#{Rubber.root}/log/*.log"]
22
+ assert_equal 1, logs.size
23
+ assert_equal "#{Rubber.root}/log/cron-sh-echo.log", logs.first
24
+ assert_match /rubber:cron running \["echo", "#{date}"\] at/, File.read(logs.first).strip
25
+ assert_match /\n#{date}$/, File.read(logs.first).strip
26
+ end
27
+
28
+ def test_rubber_cron_log_append
29
+ date = Time.now.tv_sec.to_s
30
+
31
+ out = `rubber cron echo #{date}`
32
+ assert_equal 0, $?
33
+ assert_equal "", out
34
+
35
+ out = `rubber cron echo #{date}`
36
+ assert_equal 0, $?
37
+ assert_equal "", out
38
+
39
+ logs = Dir["#{Rubber.root}/log/*.log"]
40
+ assert_equal 1, logs.size
41
+ running_lines = File.read(logs.first).lines.to_a.grep(/rubber:cron running/)
42
+ assert_equal 2, running_lines.size
43
+ end
44
+
45
+ def test_rubber_cron_logfile
46
+ date = Time.now.tv_sec.to_s
47
+ out = `rubber cron -l #{Rubber.root}/log/foo.log -- echo #{date}`
48
+ logs = Dir["#{Rubber.root}/log/*.log"]
49
+ assert_equal 1, logs.size
50
+ assert_equal "#{Rubber.root}/log/foo.log", logs.first
51
+ assert_match /\n#{date}$/, File.read(logs.first).strip
52
+ end
53
+
54
+ def test_rubber_cron_task_logfile
55
+ date = Time.now.tv_sec.to_s
56
+ out = `rubber cron --task -- cron -o -- echo #{date}`
57
+ logs = Dir["#{Rubber.root}/log/cron-task*.log"]
58
+ assert_equal 1, logs.size
59
+ assert_match /\n#{date}$/, File.read(logs.first).strip
60
+ end
61
+
62
+ def test_rubber_cron_directory_changed
63
+ out = `rubber cron -o -r /tmp -- pwd`
64
+ assert_match /(\/private)?\/tmp/, out, "Unexpected output:\n#{out}"
65
+ end
66
+
67
+ def test_rubber_cron_output_empty
68
+ out = `rubber cron -- ls -la`
69
+ assert_equal "", out, "Unexpected output:\n#{out}"
70
+ end
71
+
72
+ def test_rubber_cron_output_echoed
73
+ out = `rubber cron -o -- ls -la`
74
+ assert_not_equal "", out, "Unexpected output:\n#{out}"
75
+ end
76
+
77
+ def test_rubber_cron_output_on_error
78
+ out = `rubber cron -- ls -la jkbhbj`
79
+ assert_not_equal 0, $?
80
+ assert_not_equal "", out, "Unexpected output:\n#{out}"
81
+ end
82
+
83
+ end