caterer 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -2,3 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in caterer.gemspec
4
4
  gemspec
5
+
6
+ gem 'vagrant'
7
+ gem 'vagrant-vbguest'
8
+ gem 'berkshelf'
@@ -5,7 +5,7 @@ require 'vagrant-vbguest' unless defined? VagrantVbguest::Config
5
5
 
6
6
  Vagrant::Config.run do |config|
7
7
 
8
- config.berkshelf.config_path = './knife.rb'
8
+ # config.berkshelf.config_path = './knife.rb'
9
9
 
10
10
  config.vm.box = "precise64"
11
11
  config.vm.box_url = "http://files.vagrantup.com/precise64.box"
@@ -1,3 +1,5 @@
1
1
  Caterer.configure do |config|
2
- # nothing to see here... yet
2
+
3
+ config.provisioner.default_engine = :chef_solo
4
+
3
5
  end
@@ -20,7 +20,7 @@ module Caterer
20
20
  end
21
21
 
22
22
  def default_engine
23
- Caterer.config.default_provisioner
23
+ Caterer.config.provisioner.default_engine
24
24
  end
25
25
 
26
26
  end
@@ -1,12 +1,12 @@
1
1
  module Caterer
2
2
  module Config
3
- autoload :Base, 'caterer/config/base'
4
- autoload :Berkshelf, 'caterer/config/berkshelf'
5
- autoload :Cluster, 'caterer/config/cluster'
6
- autoload :Group, 'caterer/config/group'
7
- autoload :Member, 'caterer/config/member'
8
- autoload :Node, 'caterer/config/node'
9
- autoload :Image, 'caterer/config/image'
10
- autoload :Provision, 'caterer/config/provision'
3
+ autoload :Base, 'caterer/config/base'
4
+ autoload :Berkshelf, 'caterer/config/berkshelf'
5
+ autoload :Cluster, 'caterer/config/cluster'
6
+ autoload :Group, 'caterer/config/group'
7
+ autoload :Member, 'caterer/config/member'
8
+ autoload :Node, 'caterer/config/node'
9
+ autoload :Image, 'caterer/config/image'
10
+ autoload :Provisioner, 'caterer/config/provisioner'
11
11
  end
12
12
  end
@@ -9,7 +9,6 @@ module Caterer
9
9
  @images = {}
10
10
  @groups = {}
11
11
  @keys = {}
12
- @default_provisioner = :chef_solo
13
12
  end
14
13
 
15
14
  def image(name)
@@ -45,4 +44,6 @@ module Caterer
45
44
 
46
45
  end
47
46
  end
48
- end
47
+ end
48
+
49
+ Caterer.config_keys.register(:provisioner) { Caterer::Config::Provisioner::Base }
@@ -0,0 +1,8 @@
1
+ module Caterer
2
+ module Config
3
+ module Provisioner
4
+ autoload :Base, 'caterer/config/provisioner/base'
5
+ autoload :ChefSolo, 'caterer/config/provisioner/chef_solo'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,18 @@
1
+ module Caterer
2
+ module Config
3
+ module Provisioner
4
+ class Base
5
+ attr_accessor :default_engine
6
+
7
+ def initialize
8
+ @keys = {}
9
+ end
10
+
11
+ def chef_solo
12
+ @keys[:chef_solo] ||= Config::Provisioner::ChefSolo.new
13
+ end
14
+
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,19 @@
1
+ module Caterer
2
+ module Config
3
+ module Provisioner
4
+ class ChefSolo
5
+ attr_accessor :dest_dir, :run_list, :json, :cookbooks_path, :roles_path, :data_bags_path, :bootstrap_scripts
6
+
7
+ def initialize
8
+ @dest_dir = '/opt/cater_chef_solo'
9
+ @run_list = []
10
+ @json = {}
11
+ @cookbooks_path = ['cookbooks', 'vendor/cookbooks']
12
+ @roles_path = ['roles']
13
+ @data_bags_path = ['data_bags']
14
+ @bootstrap_scripts = []
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -9,16 +9,17 @@ module Caterer
9
9
  class ChefSolo < Base
10
10
 
11
11
  attr_reader :run_list
12
- attr_accessor :json, :cookbooks_path, :roles_path
12
+ attr_accessor :dest_dir, :json, :cookbooks_path, :roles_path
13
13
  attr_accessor :data_bags_path, :bootstrap_scripts
14
14
 
15
15
  def initialize
16
- @run_list = []
17
- @json = {}
18
- @cookbooks_path = ['cookbooks']
19
- @roles_path = ['roles']
20
- @data_bags_path = ['data_bags']
21
- @bootstrap_scripts = []
16
+ @dest_dir = config.dest_dir
17
+ @run_list = config.run_list
18
+ @json = config.json
19
+ @cookbooks_path = config.cookbooks_path
20
+ @roles_path = config.roles_path
21
+ @data_bags_path = config.data_bags_path
22
+ @bootstrap_scripts = config.bootstrap_scripts
22
23
  end
23
24
 
24
25
  # config DSL
@@ -121,8 +122,8 @@ module Caterer
121
122
 
122
123
  def prepare(server)
123
124
  # create base dir
124
- server.ssh.sudo "mkdir -p #{target_base_path}", :stream => true
125
- server.ssh.sudo "chown -R #{server.username} #{target_base_path}", :stream => true
125
+ server.ssh.sudo "mkdir -p #{dest_dir}", :stream => true
126
+ server.ssh.sudo "chown -R #{server.username} #{dest_dir}", :stream => true
126
127
  end
127
128
 
128
129
  def install(server)
@@ -185,7 +186,7 @@ module Caterer
185
186
  server.ssh.upload(StringIO.new(json_config(config_data.merge(server.data))), target_json_config_path)
186
187
 
187
188
  # set permissions on everything
188
- server.ssh.sudo "chown -R #{server.username} #{target_base_path}", :stream => true
189
+ server.ssh.sudo "chown -R #{server.username} #{dest_dir}", :stream => true
189
190
 
190
191
  # run
191
192
  server.ui.info "Running chef-solo..."
@@ -216,47 +217,47 @@ module Caterer
216
217
  def uninstall(server)
217
218
  server.ui.info "Uninstalling..."
218
219
 
219
- server.ssh.sudo "rm -rf #{target_base_path}", :stream => true
220
+ server.ssh.sudo "rm -rf #{dest_dir}", :stream => true
220
221
  end
221
222
 
222
223
  protected
223
224
 
225
+ def config
226
+ @config ||= Caterer.config.provisioner.chef_solo
227
+ end
228
+
224
229
  def with_bootstrap_scripts
225
230
  bootstrap_scripts.each_with_index do |script, index|
226
231
  yield script, index if block_given?
227
232
  end
228
233
  end
229
234
 
230
- def target_base_path
231
- "/tmp/cater-chef-solo"
232
- end
233
-
234
235
  def target_install_path
235
- "#{target_base_path}/install"
236
+ "#{dest_dir}/install"
236
237
  end
237
238
 
238
239
  def target_bootstrap_path
239
- "#{target_base_path}/bootstrap"
240
+ "#{dest_dir}/bootstrap"
240
241
  end
241
242
 
242
243
  def target_cookbooks_path
243
- "#{target_base_path}/cookbooks"
244
+ "#{dest_dir}/cookbooks"
244
245
  end
245
246
 
246
247
  def target_roles_path
247
- "#{target_base_path}/roles"
248
+ "#{dest_dir}/roles"
248
249
  end
249
250
 
250
251
  def target_data_bags_path
251
- "#{target_base_path}/data_bags"
252
+ "#{dest_dir}/data_bags"
252
253
  end
253
254
 
254
255
  def target_solo_path
255
- "#{target_base_path}/solo.rb"
256
+ "#{dest_dir}/solo.rb"
256
257
  end
257
258
 
258
259
  def target_json_config_path
259
- "#{target_base_path}/config.json"
260
+ "#{dest_dir}/config.json"
260
261
  end
261
262
 
262
263
  def install_script
@@ -1,3 +1,3 @@
1
1
  module Caterer
2
- VERSION = "0.8.0"
2
+ VERSION = "0.9.0"
3
3
  end
@@ -1,4 +1,4 @@
1
- file_cache_path "<%= target_base_path %>"
1
+ file_cache_path "<%= dest_dir %>"
2
2
  node_name "<%= server.host %>"
3
3
  cookbook_path <%= final_cookbook_paths.inspect %>
4
4
  data_bag_path "<%= target_data_bags_path %>"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caterer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-04 00:00:00.000000000 Z
12
+ date: 2013-01-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: log4r
@@ -231,6 +231,9 @@ files:
231
231
  - lib/caterer/config/group.rb
232
232
  - lib/caterer/config/image.rb
233
233
  - lib/caterer/config/member.rb
234
+ - lib/caterer/config/provisioner.rb
235
+ - lib/caterer/config/provisioner/base.rb
236
+ - lib/caterer/config/provisioner/chef_solo.rb
234
237
  - lib/caterer/environment.rb
235
238
  - lib/caterer/logger.rb
236
239
  - lib/caterer/provisioner.rb