capistrano-paratrooper-chef 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8be49d11e9096a30c6363fa3daa051b40d4bfa71
4
- data.tar.gz: 5461510219f83df619f33eff2083ee187ed47d1f
3
+ metadata.gz: 1709b90a60e5e58f7b058244cb5e984ee5b3d6c0
4
+ data.tar.gz: 706ca5d5aa700e596b6a83957747f7306db6de46
5
5
  SHA512:
6
- metadata.gz: 74d4152dc6aa3cecbc7b912989b50791c2a75014faf15c6af2da844a6bf39684df870a1ac3a49b84b39632c70fa8745bd043582d12873d5f30b49f1c6449066a
7
- data.tar.gz: ec0dc64c7224733f945ba13546746ae3c6b14a9367f47769f0f357b0c6f79ef23539e01413d2febc7dbd1f5c373ff5f8914acbd29cd3512a5f72381557434aac
6
+ metadata.gz: f7691d026c82465560421fbccbfd2db1e964a1716824be9ec631ae2566e3f78530a7cac017ebb57a25647e6aa8bed27cba9080000e081d7a84f47f66ec186565
7
+ data.tar.gz: 1a362311ae34da0fa56ed2c64c7be8bf0a3b084072f54449034b86871ce33a82421da27ca4d63ae04c225229ef0ab0f927688fd76f09d06ae528f4aa8fd4ffd1
data/README.md CHANGED
@@ -123,7 +123,8 @@ Following options are available.
123
123
  * `:chef_cookbooks_path` - cookbooks directories list. use `["cookbooks", "site-cookbooks"]` by default.
124
124
  * `:chef_nodes_path` - nodes directory. use `nodes` by default.
125
125
  * `:chef_roles_path` - roles directory. use `roles` by default.
126
- * `:chef_environments_path` - environments directory. use `environments` by default.
126
+ * `:chef_environment` - environment setting. empty by default.
127
+ * `:chef_environment_path` - environments directory. use `environments` by default.
127
128
  * `:chef_databags_path` - data bags directory. use `data_bags` by default.
128
129
  * `:chef_databag_secret` - path of secret-key for data bags. use `data_bag_key` by default.
129
130
 
@@ -28,7 +28,8 @@ Capistrano::Configuration.instance.load do
28
28
  set :chef_nodes_path, "nodes"
29
29
  set :chef_cookbooks_path, ["cookbooks", "site-cookbooks"]
30
30
  set :chef_roles_path, "roles"
31
- set :chef_environments_path, "environments"
31
+ set :chef_environment, nil
32
+ set :chef_environment_path, "environments"
32
33
  set :chef_databags_path, "data_bags"
33
34
  set :chef_databag_secret, "data_bag_key"
34
35
 
@@ -93,8 +94,8 @@ Capistrano::Configuration.instance.load do
93
94
  File.exist?(File.join(roles_path, name.to_s + ".rb"))
94
95
  end
95
96
 
96
- def environments_path
97
- File.join(fetch(:chef_kitchen_path), fetch(:chef_environments_path))
97
+ def environment_path
98
+ File.join(fetch(:chef_kitchen_path), fetch(:chef_environment_path))
98
99
  end
99
100
 
100
101
  def databags_path
@@ -111,33 +112,36 @@ Capistrano::Configuration.instance.load do
111
112
 
112
113
 
113
114
  namespace :run_list do
114
- def solo_json_path_for(name)
115
- path = File.join(nodes_path, name.to_s + ".json")
116
- if File.exist?(path)
117
- path
118
- else
119
- File.join(fetch(:chef_kitchen_path), fetch(:chef_default_solo_json_path))
120
- end
115
+ def solo_json_paths_for(name)
116
+ [File.join(nodes_path, name.to_s + ".json"),
117
+ File.join(fetch(:chef_kitchen_path), fetch(:chef_default_solo_json_path))]
121
118
  end
122
119
 
123
120
  def discover
124
121
  find_servers_for_task(current_task).each do |server|
125
- begin
126
- open(solo_json_path_for(server.host)) do |fd|
127
- server.options[:chef_attributes] = JSON.load(fd)
122
+ solo_json_paths = solo_json_paths_for(server.host)
123
+ solo_json_paths.each do |path|
124
+ next if not File.exist?(path)
125
+
126
+ begin
127
+ open(path) do |fd|
128
+ server.options[:chef_attributes] = JSON.load(fd)
128
129
 
129
- if server.options[:chef_attributes]["run_list"].nil?
130
- server.options[:chef_attributes]["run_list"] = []
130
+ if server.options[:chef_attributes]["run_list"].nil?
131
+ server.options[:chef_attributes]["run_list"] = []
132
+ end
131
133
  end
134
+ break
135
+ rescue JSON::ParserError
136
+ logger.important("Could not parse JSON file: %s" % path)
137
+ rescue => e
138
+ logger.important("Could not read JSON file: %s" % e)
132
139
  end
133
- rescue JSON::ParserError
134
- logger.important("Could not parse JSON file: %s" % solo_json_path_for(server.host))
135
- rescue
136
- logger.important("Could not read JSON file: %s" % solo_json_path_for(server.host))
137
- ensure
138
- if server.options[:chef_attributes].nil?
139
- server.options[:chef_attributes] = {"run_list" => []}
140
- end
140
+ end
141
+
142
+ if server.options[:chef_attributes].nil?
143
+ logger.important("any JSON file not found: %s" % solo_json_paths.inspect)
144
+ server.options[:chef_attributes] = {"run_list" => []}
141
145
  end
142
146
 
143
147
  if fetch(:chef_roles_auto_discovery)
@@ -193,7 +197,8 @@ Capistrano::Configuration.instance.load do
193
197
  file_cache_path #{fetch(:chef_cache_dir).inspect}
194
198
  cookbook_path #{kitchen.cookbooks_paths.inspect}.collect{|dir| File.join(root, dir)}
195
199
  role_path File.join(root, #{kitchen.roles_path.inspect})
196
- environments_path File.join(root, #{kitchen.environments_path.inspect})
200
+ environment #{fetch(:chef_environment).to_s.inspect}
201
+ environment_path File.join(root, #{kitchen.environment_path.inspect})
197
202
  data_bag_path File.join(root, #{kitchen.databags_path.inspect})
198
203
  verbose_logging #{fetch(:chef_verbose_logging)}
199
204
  CONF
@@ -264,7 +269,7 @@ Capistrano::Configuration.instance.load do
264
269
 
265
270
  def ensure_cookbooks
266
271
  abort "No cookbooks found in #{fetch(:cookbooks_directory).inspect}" if kitchen.cookbooks_paths.empty?
267
- abort "Multiple cookbook definitions found: Cheffile, Berksfile" if File.exist? 'Cheffile' and File.exsit? 'Berksfile'
272
+ abort "Multiple cookbook definitions found: Cheffile, Berksfile" if File.exist? 'Cheffile' and File.exist? 'Berksfile'
268
273
  end
269
274
 
270
275
  def ensure_working_dir
@@ -279,7 +284,7 @@ Capistrano::Configuration.instance.load do
279
284
 
280
285
  stream = StringIO.new
281
286
  TarWriter.new(stream) do |writer|
282
- paths = [cookbooks_paths, roles_path, environments_path, databags_path, databag_secret_path]
287
+ paths = [cookbooks_paths, roles_path, environment_path, databags_path, databag_secret_path]
283
288
  kitchen_paths = paths.flatten.compact.select{|d| File.exists?(d)}
284
289
  Find.find(*kitchen_paths) do |path|
285
290
  writer.add(path)
@@ -16,7 +16,7 @@
16
16
  module Capistrano
17
17
  module Paratrooper
18
18
  module Chef
19
- VERSION = "0.3.0"
19
+ VERSION = "0.4.0"
20
20
  end
21
21
  end
22
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-paratrooper-chef
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takeshi KOMIYA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-28 00:00:00.000000000 Z
11
+ date: 2013-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano