lobot 0.9.2 → 0.9.4

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/README.md CHANGED
@@ -16,13 +16,17 @@ all you'll need to do is:
16
16
 
17
17
  rails g lobot:install
18
18
  edit config/ci.yml
19
- rake ci:server_start && cap ci bootstrap && cap ci chef
19
+ rake ci:server_start
20
+ cap ci bootstrap
21
+ cap ci chef
22
+
23
+ Read on for an explanation of what each one of these steps does.
20
24
 
21
25
  ## Install
22
26
 
23
- Add lobot to your Gemfile
27
+ Add lobot to your Gemfile, in the development group:
24
28
 
25
- gem "lobot"
29
+ gem "lobot", :group => :development
26
30
 
27
31
  ## Generate
28
32
  Lobot is a Rails 3 generator. Rails 2 can be made to work, but you will need to copy the template files into your project.
@@ -58,6 +62,24 @@ Edit config/ci.yml
58
62
 
59
63
  For security, you can add ci.yml to your .gitignore file and store a ci.yml.example without authentication credentials in your repository
60
64
 
65
+ ## Modify the soloistrc if necessary
66
+
67
+ Switch postgres to mysql, or add your own recipes for your own dependencies.
68
+
69
+ ## Let 'er rip
70
+
71
+ Launch an instance, allocate and associates an elastic IP and updates ci.yml:
72
+
73
+ rake ci:server_start
74
+
75
+ Bootstrap the instance using the boostrap_server.sh script generated by Lobot. The script instals ruby prerequisites, creates the app_user account, and installs RVM for that user:
76
+
77
+ cap ci bootstrap
78
+
79
+ Upload the contents of your chef/cookbooks/ directory, upload the soloistrc, and run chef:
80
+
81
+ cap ci chef
82
+
61
83
  ## Dependencies
62
84
 
63
85
  * fog
data/features/ci.feature CHANGED
@@ -18,3 +18,11 @@ Feature: CI
18
18
  And I bootstrap
19
19
  And I deploy
20
20
  Then CI is green
21
+
22
+ Scenario: Installing Lobot on a rails3 project
23
+ When I create a new Rails project using a Rails template
24
+ And I vendor Lobot
25
+ And I put Lobot in the Gemfile
26
+ And I run bundle install
27
+ And I run the Lobot generator
28
+ Then rake reports ci tasks as being available
@@ -100,3 +100,7 @@ Then /^CI is green$/ do
100
100
  end
101
101
  end
102
102
  end
103
+
104
+ Then /^rake reports ci tasks as being available$/ do
105
+ `cd testapp && rake -T`.should include("ci:start")
106
+ end
@@ -4,7 +4,6 @@ module Lobot
4
4
 
5
5
  def create_ci_files
6
6
  template 'ci.yml', 'config/ci.yml'
7
- template 'ci.rake', 'lib/tasks/ci.rake'
8
7
  template 'bootstrap_server.sh', 'script/bootstrap_server.sh'
9
8
  template 'deploy-ci.rb', 'config/deploy/ci.rb'
10
9
  template 'capistrano-ci.rb', 'config/capistrano/ci.rb'
@@ -39,7 +39,7 @@ set -e
39
39
  export APP_USER=$1
40
40
 
41
41
  mkdir -p /home/$APP_USER/rvm/src
42
- curl -Lskf http://github.com/wayneeseguin/rvm/tarball/7680ad29b90cfcc59f3588a6d1fc7c2806df9f19 | tar xvz -C/home/$APP_USER/rvm/src --strip 1
42
+ curl -Lskf http://github.com/wayneeseguin/rvm/tarball/0f7135af8f0b6139716637d242a82442dd7fef09 | tar xvz -C/home/$APP_USER/rvm/src --strip 1
43
43
  cd "/home/$APP_USER/rvm/src" && ./install
44
44
 
45
45
  rvm_include_string='[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"'
@@ -1,8 +1,9 @@
1
1
  include_recipe "pivotal_server::imagemagick"
2
- include_recipe "pivotal_server::postgres"
3
2
  include_recipe "pivotal_server::sqlite"
4
3
  include_recipe "pivotal_server::libxml_prereqs"
5
4
  include_recipe "pivotal_server::nginx"
5
+ include_recipe "pivotal_server::file"
6
+ include_recipe "pivotal_server::curl_devel"
6
7
  include_recipe "pivotal_server::ca_cert"
7
8
  include_recipe "pivotal_server::node_js"
8
9
  include_recipe "pivotal_ci::id_rsa"
@@ -1,24 +1,7 @@
1
- # include_recipe "pivotal_server::daemontools"
2
-
3
- # service_name = "xvfb"
4
-
5
1
  execute "install xvfb" do
6
2
  command "yum -y install xorg-x11-server-Xvfb"
7
3
  end
8
4
 
9
5
  execute "install firefox" do
10
6
  command "yum -y install firefox"
11
- end
12
-
13
- # execute "make daemontools dir" do
14
- # command "mkdir -p /service/#{service_name}"
15
- # end
16
- #
17
- # execute "create run script3" do # srsly! the not_if from mysql was being applied because they had the same name. I kid you not.
18
- # command "echo -e '#!/bin/sh\nexec Xvfb :99 -ac -screen 0 1024x768x16' > /service/#{service_name}/run"
19
- # # not_if "ls /service/#{service_name}/run"
20
- # end
21
- #
22
- # execute "make run script executable" do
23
- # command "chmod 755 /service/#{service_name}/run"
24
- # end
7
+ end
@@ -0,0 +1,3 @@
1
+ yum_package "curl-devel" do
2
+ action :install
3
+ end
@@ -0,0 +1,19 @@
1
+ src_dir = "/usr/local/src/file"
2
+
3
+ run_unless_marker_file_exists("file") do
4
+ execute "download file src" do
5
+ command "mkdir -p #{src_dir} && curl -Lsf ftp://ftp.astron.com/pub/file/file-5.08.tar.gz | tar xvz -C#{src_dir} --strip 1"
6
+ end
7
+
8
+ execute "configure file" do
9
+ command "cd #{src_dir} && ./configure"
10
+ end
11
+
12
+ execute "make file" do
13
+ command "cd #{src_dir} && make"
14
+ end
15
+
16
+ execute "install file" do
17
+ command "cd #{src_dir} && make install"
18
+ end
19
+ end
@@ -35,3 +35,11 @@ run_unless_marker_file_exists("imagemagick_6_6_5") do
35
35
  cwd src_dir
36
36
  end
37
37
  end
38
+
39
+ file "/etc/ld.so.conf.d/imagemagick.conf" do
40
+ content "/usr/local/lib"
41
+ end
42
+
43
+ execute "add imagemagick to ldconf" do
44
+ command "/sbin/ldconfig"
45
+ end
@@ -0,0 +1,28 @@
1
+ include_recipe "pivotal_server::daemontools"
2
+
3
+ install_dir = "/usr/local/mongo"
4
+
5
+ user "mongo"
6
+
7
+ run_unless_marker_file_exists("mongo_2_0") do
8
+ execute "download mongo" do
9
+ command "mkdir -p #{install_dir} && curl -Lsf http://downloads.mongodb.org/linux/mongodb-linux-i686-2.0.0.tgz | tar xvz -C#{install_dir} --strip 1"
10
+ end
11
+
12
+ execute "mongo owns #{install_dir}/data" do
13
+ command "mkdir -p #{install_dir}/data && chown -R mongo #{install_dir}/data"
14
+ end
15
+ end
16
+
17
+ execute "create daemontools directory" do
18
+ command "mkdir -p /service/mongo"
19
+ end
20
+
21
+ execute "create run script" do
22
+ command "echo -e '#!/bin/sh\nexec /command/setuidgid mongo /usr/local/mongo/bin/mongod --dbpath #{install_dir}/data' > /service/mongo/run"
23
+ not_if "ls /service/mongo/run"
24
+ end
25
+
26
+ execute "make run script executable" do
27
+ command "chmod 755 /service/mongo/run"
28
+ end
@@ -18,13 +18,13 @@ end
18
18
 
19
19
  user "mysql"
20
20
 
21
- run_unless_marker_file_exists("mysql_5_1") do
21
+ run_unless_marker_file_exists("mysql_5_1_with_innodb") do
22
22
  execute "download mysql src" do
23
23
  command "mkdir -p #{src_dir} && curl -Lsf http://mysql.he.net/Downloads/MySQL-5.1/mysql-5.1.57.tar.gz | tar xvz -C#{src_dir} --strip 1"
24
24
  end
25
25
 
26
26
  execute "configure" do
27
- command "./configure --prefix=/usr/local/mysql"
27
+ command "./configure --prefix=/usr/local/mysql --with-plugins=innobase,myisam"
28
28
  cwd src_dir
29
29
  end
30
30
 
@@ -48,6 +48,20 @@ run_unless_marker_file_exists("mysql_5_1") do
48
48
  end
49
49
  end
50
50
 
51
+ file "/etc/ld.so.conf.d/mysql-64.conf" do
52
+ content "/usr/local/mysql/lib/mysql/"
53
+ end
54
+
55
+ execute "add mysql to ldconf" do
56
+ command "/sbin/ldconfig"
57
+ end
58
+
59
+ template "/etc/my.cnf" do
60
+ source "my-conf.erb"
61
+ owner "mysql"
62
+ mode "0644"
63
+ end
64
+
51
65
  execute "create daemontools directory" do
52
66
  command "mkdir -p /service/mysql"
53
67
  end
@@ -87,4 +101,8 @@ end
87
101
 
88
102
  execute "grant user all rights (this maybe isn't a great idea)" do
89
103
  command "#{install_dir}/bin/mysql -u root -p#{mysql_root_password} -D mysql -r -B -N -e \"GRANT ALL on *.* to '#{mysql_user_name}'@'localhost'\""
90
- end
104
+ end
105
+
106
+ execute "insert time zone info" do
107
+ command "#{install_dir}/bin/mysql_tzinfo_to_sql /usr/share/zoneinfo | #{install_dir}/bin/mysql -uroot -p#{mysql_root_password} mysql"
108
+ end
@@ -0,0 +1,2 @@
1
+ [mysqld]
2
+ default-storage-engine = innodb
@@ -1,5 +1,5 @@
1
1
  require 'yaml'
2
2
  aws_conf_location = File.expand_path('../../ci.yml', __FILE__)
3
- ci_server = YAML.load_file(aws_conf_location)["server"]['name']
3
+ ci_server = YAML.load_file(aws_conf_location)["server"]['elastic_ip']
4
4
 
5
5
  role :ci, ci_server
@@ -1,6 +1,8 @@
1
1
  cookbook_paths:
2
2
  - ./chef/cookbooks/
3
3
  recipes:
4
+ # - pivotal_server::mysql_5_5
5
+ - pivotal_server::postgres
4
6
  - pivotal_ci::default
5
7
  env_variable_switches:
6
8
  APP_NAME:
data/lib/lobot.rb CHANGED
@@ -1,4 +1,14 @@
1
1
  require File.expand_path('lobot/version', File.dirname(__FILE__))
2
2
 
3
3
  module Lobot
4
+ def self.rails3?
5
+ return Rails.version.split(".").first.to_i == 3 if defined? Rails
6
+ begin
7
+ Gem::Specification::find_by_name "rails", ">= 3.0"
8
+ rescue
9
+ Gem.available? "rails", ">= 3.0"
10
+ end
11
+ end
4
12
  end
13
+
14
+ require File.expand_path(File.join('lobot', "railtie"), File.dirname(__FILE__)) if Lobot.rails3?
@@ -0,0 +1,20 @@
1
+ require "rails/railtie"
2
+ module Lobot
3
+ class Railtie < Rails::Railtie
4
+
5
+ config.before_configuration do
6
+ old_lobot_rakefile = ::Rails.root.join('lib', 'tasks', 'ci.rake')
7
+ if old_lobot_rakefile.exist? && !ENV["USE_CI_RAKE"]
8
+ puts %Q{
9
+ You no longer need to have ci.rake in your project, as it is now automatically loaded
10
+ from the Lobot gem. To silence this warning, set "USE_CI_RAKE=true" in your environment
11
+ or remove ci.rake.
12
+ }
13
+ end
14
+ end
15
+
16
+ rake_tasks do
17
+ load "lobot/tasks/ci.rake"
18
+ end
19
+ end
20
+ end
@@ -5,7 +5,7 @@ namespace :ci do
5
5
  require 'yaml'
6
6
  require 'socket'
7
7
 
8
- aws_conf_location = File.expand_path('../../../config/ci.yml', __FILE__)
8
+ aws_conf_location = File.join(Dir.pwd, 'config', 'ci.yml')
9
9
  aws_conf = YAML.load_file(aws_conf_location)
10
10
  aws_credentials = aws_conf['credentials']
11
11
  ec2_server_access = aws_conf['ec2_server_access']
@@ -64,14 +64,23 @@ namespace :ci do
64
64
  :key_name => ec2_key_pair_name,
65
65
  :groups => [security_group_name]
66
66
  )
67
+
68
+ unless aws_conf['server']['elastic_ip'] =~ /\d.\.\d.\.\d.\.\d./
69
+ elastic_ip = aws_connection.addresses.create
70
+ aws_conf['server']['elastic_ip'] = elastic_ip.public_ip
71
+ puts "Allocated elastic IP address #{aws_conf['server']['elastic_ip']}"
72
+ end
73
+
67
74
  server.wait_for { ready? }
68
75
 
76
+ aws_connection.associate_address(server.id, aws_conf['server']['elastic_ip'])
77
+
69
78
  socket = false
70
79
  Timeout::timeout(120) do
71
80
  p "Server booted, waiting for SSH."
72
81
  until socket
73
82
  begin
74
- socket = TCPSocket.open(server.dns_name, 22)
83
+ socket = TCPSocket.open(aws_conf['server']['elastic_ip'], 22)
75
84
  rescue Errno::ECONNREFUSED
76
85
  STDOUT << "."
77
86
  STDOUT.flush
@@ -83,38 +92,82 @@ namespace :ci do
83
92
  p server
84
93
  puts "Server is ready"
85
94
 
86
- p "Writing server public IP (#{server.dns_name}) to ci.yml"
87
- aws_conf["server"].merge!("name" => server.dns_name, "instance_id" => server.id)
95
+ p "Writing server instance_id(#{server.id}) and elastic IP(#{aws_conf['server']['elastic_ip']}) to ci.yml"
96
+ aws_conf["server"].merge!("instance_id" => server.id)
88
97
 
89
98
  f = File.open(aws_conf_location, "w")
90
99
  f.write(aws_conf.to_yaml)
91
100
  f.close
92
101
  end
93
102
 
103
+ desc "stop(suspend) the CI Server"
104
+ task :stop do
105
+ require 'fog'
106
+ require 'yaml'
107
+ require 'socket'
108
+
109
+ aws_conf_location = File.join(Dir.pwd, 'config', 'ci.yml')
110
+ aws_conf = YAML.load_file(aws_conf_location)
111
+ aws_credentials = aws_conf['credentials']
112
+ server_config = aws_conf['server']
113
+
114
+ aws_connection = Fog::Compute.new(
115
+ :provider => aws_credentials['provider'],
116
+ :aws_access_key_id => aws_credentials['aws_access_key_id'],
117
+ :aws_secret_access_key => aws_credentials['aws_secret_access_key']
118
+ )
119
+
120
+ aws_connection.servers.new(:id => server_config['instance_id']).stop
121
+ end
122
+
123
+ desc "start(resume) the CI Server"
124
+ task :start do
125
+ require 'fog'
126
+ require 'yaml'
127
+ require 'socket'
128
+
129
+ aws_conf_location = File.join(Dir.pwd, 'config', 'ci.yml')
130
+ aws_conf = YAML.load_file(aws_conf_location)
131
+ aws_credentials = aws_conf['credentials']
132
+ server_config = aws_conf['server']
133
+
134
+ aws_connection = Fog::Compute.new(
135
+ :provider => aws_credentials['provider'],
136
+ :aws_access_key_id => aws_credentials['aws_access_key_id'],
137
+ :aws_secret_access_key => aws_credentials['aws_secret_access_key']
138
+ )
139
+
140
+ server = aws_connection.servers.new(:id => server_config['instance_id'])
141
+ # server.start
142
+ server.wait_for { ready? }
143
+
144
+ aws_connection.associate_address(server_config['instance_id'], server_config['elastic_ip']) if server_config['elastic_ip']
145
+ end
146
+
94
147
  desc "open the CI interface in a browser"
95
148
  task :open do
96
- aws_conf_location = File.expand_path('../../../config/ci.yml', __FILE__)
149
+ aws_conf_location = File.join(Dir.pwd, 'config', 'ci.yml')
97
150
  aws_conf = YAML.load_file(aws_conf_location)
98
151
  server_config = aws_conf['server']
99
- exec "open http://#{server_config['name']}"
152
+ exec "open http://#{server_config['elastic_ip']}"
100
153
  end
101
154
 
102
155
  desc "ssh to CI"
103
156
  task :ssh do
104
- aws_conf_location = File.expand_path('../../../config/ci.yml', __FILE__)
157
+ aws_conf_location = File.join(Dir.pwd, 'config', 'ci.yml')
105
158
  aws_conf = YAML.load_file(aws_conf_location)
106
159
  server_config = aws_conf['server']
107
- exec "ssh -i #{aws_conf['ec2_server_access']['id_rsa_path']} #{aws_conf['app_user']}@#{server_config['name']}"
160
+ exec "ssh -i #{aws_conf['ec2_server_access']['id_rsa_path']} #{aws_conf['app_user']}@#{server_config['elastic_ip']}"
108
161
  end
109
162
 
110
163
  desc "Get build status"
111
164
  task :status do
112
165
  require 'nokogiri'
113
- ci_conf_location = File.expand_path('../../../config/ci.yml', __FILE__)
114
- ci_conf = YAML.load_file(ci_conf_location)
166
+ aws_conf_location = File.join(Dir.pwd, 'config', 'ci.yml')
167
+ ci_conf = YAML.load_file(aws_conf_location)
115
168
 
116
- hudson_rss_feed = `curl -s --user #{ci_conf['basic_auth'][0]['username']}:#{ci_conf['basic_auth'][0]['password']} --anyauth http://#{ci_conf['server']['name']}/rssAll`
117
- latest_build = Nokogiri::XML.parse(hudson_rss_feed.downcase).css('feed entry:first').first
169
+ jenkins_rss_feed = `curl -s --user #{ci_conf['basic_auth'][0]['username']}:#{ci_conf['basic_auth'][0]['password']} --anyauth http://#{ci_conf['server']['elastic_ip']}/rssAll`
170
+ latest_build = Nokogiri::XML.parse(jenkins_rss_feed.downcase).css('feed entry:first').first
118
171
  status = !!(latest_build.css("title").first.content =~ /success|stable|back to normal/)
119
172
  if status
120
173
  p "Great Success"
data/lib/lobot/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lobot
2
- VERSION = "0.9.2"
2
+ VERSION = "0.9.4"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lobot
3
3
  version: !ruby/object:Gem::Version
4
- hash: 63
4
+ hash: 51
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 2
10
- version: 0.9.2
9
+ - 4
10
+ version: 0.9.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matthew Kocher & Lee Edwards
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-13 00:00:00 Z
18
+ date: 2011-11-03 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: fog
@@ -128,9 +128,12 @@ files:
128
128
  - lib/generators/lobot/templates/chef/cookbooks/pivotal_server/files/default/cacert.pem
129
129
  - lib/generators/lobot/templates/chef/cookbooks/pivotal_server/libraries/marker.rb
130
130
  - lib/generators/lobot/templates/chef/cookbooks/pivotal_server/recipes/ca_cert.rb
131
+ - lib/generators/lobot/templates/chef/cookbooks/pivotal_server/recipes/curl_devel.rb
131
132
  - lib/generators/lobot/templates/chef/cookbooks/pivotal_server/recipes/daemontools.rb
133
+ - lib/generators/lobot/templates/chef/cookbooks/pivotal_server/recipes/file.rb
132
134
  - lib/generators/lobot/templates/chef/cookbooks/pivotal_server/recipes/imagemagick.rb
133
135
  - lib/generators/lobot/templates/chef/cookbooks/pivotal_server/recipes/libxml_prereqs.rb
136
+ - lib/generators/lobot/templates/chef/cookbooks/pivotal_server/recipes/mongo_2_0.rb
134
137
  - lib/generators/lobot/templates/chef/cookbooks/pivotal_server/recipes/mysql_5_1.rb
135
138
  - lib/generators/lobot/templates/chef/cookbooks/pivotal_server/recipes/mysql_5_5.rb
136
139
  - lib/generators/lobot/templates/chef/cookbooks/pivotal_server/recipes/nginx.rb
@@ -138,16 +141,18 @@ files:
138
141
  - lib/generators/lobot/templates/chef/cookbooks/pivotal_server/recipes/postgres.rb
139
142
  - lib/generators/lobot/templates/chef/cookbooks/pivotal_server/recipes/sqlite.rb
140
143
  - lib/generators/lobot/templates/chef/cookbooks/pivotal_server/recipes/swap.rb
144
+ - lib/generators/lobot/templates/chef/cookbooks/pivotal_server/templates/default/my-conf.erb
141
145
  - lib/generators/lobot/templates/chef/cookbooks/pivotal_server/templates/default/nginx-conf.erb
142
146
  - lib/generators/lobot/templates/chef/cookbooks/pivotal_server/templates/default/nginx-htaccess.erb
143
147
  - lib/generators/lobot/templates/chef/cookbooks/pivotal_server/templates/default/nginx-mime-types.erb
144
148
  - lib/generators/lobot/templates/chef/cookbooks/pivotal_server/templates/default/nginx-run-script.erb
145
149
  - lib/generators/lobot/templates/chef/cookbooks/pivotal_server/templates/default/postgres-run-script.erb
146
- - lib/generators/lobot/templates/ci.rake
147
150
  - lib/generators/lobot/templates/ci.yml
148
151
  - lib/generators/lobot/templates/deploy-ci.rb
149
152
  - lib/generators/lobot/templates/soloistrc
150
153
  - lib/lobot.rb
154
+ - lib/lobot/railtie.rb
155
+ - lib/lobot/tasks/ci.rake
151
156
  - lib/lobot/version.rb
152
157
  - lobot.gemspec
153
158
  - spec/install_spec.rb
@@ -181,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
186
  requirements: []
182
187
 
183
188
  rubyforge_project: lobot
184
- rubygems_version: 1.8.11
189
+ rubygems_version: 1.8.6
185
190
  signing_key:
186
191
  specification_version: 3
187
192
  summary: Lobot provides generators of chef recipes to set up CI easily.