knife-stackbuilder 0.5.7 → 0.5.8

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 278edc9ab005e30e5b5da72cd13e7e28a49df655
4
- data.tar.gz: 0ee5c8dc89f98d4cfdcd6d0db3cd040789fa2a52
3
+ metadata.gz: aedb4132378ee68d7c8e56a485173de58d61a428
4
+ data.tar.gz: 9fa027941863f5f08a5bdc41944256fbf728a348
5
5
  SHA512:
6
- metadata.gz: 463be1cca68ecdc686bb7f4e985b2e7f79a8e443605b142078a1fc2be0891327fa68b35be85a8283fdda7750ff789b5eaa38b299fa631b96eeba4de5cd2dc11a
7
- data.tar.gz: 9336cb38c175d9cc6daaf14b70883adb13038c7ec1e7d323754e44b651d70309731ea908d85bdcd5f917b6f37a5f5e2e6592c182a33bbe2cd92922121830e340
6
+ metadata.gz: db532af7b3a449f18f47724bc7c098440cfd0f0aeda34eb6434701db013603295e3445168f9124cea1b49fc6ec21ae821275275d62b19f40f366101368d5c879
7
+ data.tar.gz: 72b4d0c1b30a929468d089d8530cd1063904eee27e4bb58b300a64d76fa1bbaa2787305229a79664a9bbfa624fb466e3643eacce75e5f6c403fabc0d7dd23f7c
@@ -42,7 +42,7 @@ module StackBuilder::Chef
42
42
 
43
43
  @environments = [ ]
44
44
  Dir["#{@repo_path}/environments/**/*.rb"].each do |envfile|
45
- @environments << envfile[/\/(\w+).rb$/, 1]
45
+ @environments << File.basename(envfile, ".rb")
46
46
  end
47
47
 
48
48
  @logger.debug("Found stack environments #{@environments}")
@@ -119,6 +119,8 @@ module StackBuilder::Chef
119
119
  knife_cmd = Chef::Knife::DataBagList.new
120
120
  data_bag_list = run_knife(knife_cmd).split
121
121
 
122
+ environments = (environment.nil? ? @environments : [ environment ])
123
+
122
124
  # Create environment specific data bags to hold certificates
123
125
  @environments.each do |env_name|
124
126
 
@@ -30,7 +30,14 @@ module StackBuilder::Chef
30
30
 
31
31
  target_node_instance = "#{target.node_id}-#{index}"
32
32
  node = Chef::Node.load(target_node_instance)
33
- ipaddress = node.attributes['ipaddress']
33
+
34
+ if @knife_config.has_key?('ip_attribute')
35
+
36
+ v = lambda { |h,k| k.size>1 ? v.call(h[k.shift],k) : h[k.shift] }
37
+ ipaddress = v.call(node.attributes, @knife_config['ip_attribute'].split('.'))
38
+ else
39
+ ipaddress = node.attributes['ipaddress']
40
+ end
34
41
 
35
42
  ssh = ssh_create(ipaddress, target.ssh_user,
36
43
  target.ssh_password.nil? ? target.ssh_identity_file : target.ssh_password)
@@ -54,6 +54,8 @@ module StackBuilder::Chef
54
54
  config_knife(knife_cmd, knife_config['delete']['options'] || { })
55
55
  config_knife(knife_cmd, knife_config['options'] || { })
56
56
 
57
+ knife_cmd.config[:yes] = true
58
+
57
59
  if knife_config['delete']['synchronized']
58
60
  @@sync ||= Mutex.new
59
61
  @@sync.synchronize {
@@ -213,7 +213,9 @@ module StackBuilder::Chef
213
213
 
214
214
  def knife_ssh(name, cmd)
215
215
 
216
- sudo = @knife_config['options']['sudo'] ? 'sudo -i su -c ' : ''
216
+ knife_config_options = @knife_config['options'] || { }
217
+
218
+ sudo = knife_config_options['sudo'] ? 'sudo -i su -c ' : ''
217
219
 
218
220
  ssh_cmd = "TMPFILE=`mktemp` && " +
219
221
  "echo -e \"#{cmd.gsub(/\"/, "\\\"").gsub(/\$/, "\\$").gsub(/\`/, '\\' + '\`')}\" > $TMPFILE && " +
@@ -223,9 +225,9 @@ module StackBuilder::Chef
223
225
 
224
226
  knife_cmd = Chef::Knife::Ssh.new
225
227
  knife_cmd.name_args = [ "name:#{name}", ssh_cmd ]
226
- knife_cmd.config[:attribute] = 'ipaddress'
228
+ knife_cmd.config[:attribute] = knife_config_options['ip_attribute'] || 'ipaddress'
227
229
 
228
- config_knife(knife_cmd, @knife_config['options'] || { })
230
+ config_knife(knife_cmd, knife_config_options)
229
231
 
230
232
  if @logger.info? || @logger.debug?
231
233
 
@@ -40,6 +40,12 @@ module StackBuilder::Chef
40
40
  raise ArgmentError, "Stack file is fixed to the environment '#{stack_environment}', " +
41
41
  " which it does not match the environment '#{@environment}' provided." \
42
42
  unless stack_environment.nil? || stack_environment==@environment
43
+
44
+ unless stack['chef'].nil?
45
+
46
+ stack['chef']['knife_config'].each { |k,v| Chef::Config[:knife][k.to_sym] = v } \
47
+ if stack['chef'].has_key?('knife_config')
48
+ end
43
49
  end
44
50
 
45
51
  def get_env_vars
@@ -1,7 +1,9 @@
1
- name "<%= @environment %>"
2
- description "Chef '<%= @environment %>' environment."
1
+ env_name = File.basename( __FILE__, ".rb")
3
2
 
4
- env = YAML.load_file(File.expand_path('../../etc/<%= @environment %>.yml', __FILE__))
3
+ name env_name
4
+ description "Chef '#{env_name}' environment."
5
+
6
+ env = YAML.load_file(File.expand_path("../../etc/#{env_name}.yml", __FILE__))
5
7
 
6
8
  override_attributes(
7
9
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Knife
4
4
  module StackBuilder
5
- VERSION = "0.5.7"
5
+ VERSION = "0.5.8"
6
6
  MAJOR, MINOR, TINY = VERSION.split('.')
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-stackbuilder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.7
4
+ version: 0.5.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mevan Samaratunga
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-31 00:00:00.000000000 Z
11
+ date: 2015-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef