knife-nodefu 0.4.2 → 0.4.3

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.
@@ -64,21 +64,21 @@ class NodefuCreate < Chef::Knife
64
64
 
65
65
  def run
66
66
  check_args(1)
67
-
68
- base_name, start_range, end_range = parse_servers(name_args[0])
69
67
 
70
- env = Chef::Config[:environment]
71
- defs_dir = Chef::Config[:nodefu_definitions] || config[:definitions]
68
+ base_name, start_range, end_range = parse_servers(name_args[0])
69
+
70
+ env = Chef::Config[:environment]
71
+ defs_dir = Chef::Config[:nodefu_definitions] || config[:definitions]
72
72
  yml_config = definitions_from_directory defs_dir
73
73
  merged_config = Chef::Mixin::DeepMerge.merge(yml_config['default'], yml_config['env'][env])
74
- node_spec_name = config[:node_spec] || base_name
74
+ node_spec_name = config[:node_spec] || base_name
75
75
  abort("I'm sorry I couldn't find any node_spec matches :(") unless (node_spec = merged_config['node_spec'][node_spec_name])
76
76
 
77
- domain = merged_config['domain']
77
+ domain = merged_config['domain']
78
78
  vm_spec_name = node_spec['vm_spec']
79
79
  vm_spec = merged_config['vm_spec'][vm_spec_name]
80
80
  group_ids = node_spec['group_ids'] ||= []
81
- aux_groups = node_spec['aux_groups'] ||= []
81
+ aux_groups = node_spec['aux_groups'] ||= []
82
82
 
83
83
  elastic_ip_address = node_spec['elastic_ip_address']
84
84
  private_ip_address = node_spec['private_ip_address']
@@ -95,7 +95,7 @@ class NodefuCreate < Chef::Knife
95
95
  ui.msg("#{ui.color('VPC Mode',:cyan)}: #{is_vpc?(node_spec)}")
96
96
  pretty_print_hash(node_spec)
97
97
  pretty_print_hash(vm_spec)
98
-
98
+
99
99
  unless config[:disable_default_groups] || is_vpc?(node_spec)
100
100
  ui.msg("#{ui.color('Auto generated security groups',:cyan)}: #{generate_security_groups("#{base_name}#{start_range}-#{end_range}",env,domain)}")
101
101
  end
@@ -103,28 +103,28 @@ class NodefuCreate < Chef::Knife
103
103
  config[:yes] ? user_response = 'yes' : user_response = ui.ask_question("Does this seem right to you? [y/n]").downcase
104
104
  abort("See ya!") unless (['yes','y',].include?(user_response))
105
105
 
106
- threads = []
106
+ threads = []
107
107
  sema = Mutex.new
108
108
  for i in (start_range..end_range)
109
109
  ec2_server_request = Ec2ServerCreate.new
110
110
  node_name = "#{base_name}#{i}"
111
- full_node_name = "#{node_name}.#{env}.#{domain}"
111
+ full_node_name = "#{node_name}.#{env}.#{domain}"
112
112
  security_groups = if config[:disable_default_groups]
113
113
  aux_groups
114
114
  else
115
- generate_security_groups(node_name,env,domain) + aux_groups
115
+ generate_security_groups(node_name,env,domain) + aux_groups
116
116
  end unless is_vpc?(node_spec)
117
117
  security_group_ids = group_ids
118
118
 
119
119
  # A handfull of the Ec2ServerCreate command line options use a :proc field so I have to
120
- # populate those by hand instead of simply passing a value to its config entry
120
+ # populate those by hand instead of simply passing a value to its config entry
121
121
  Chef::Config[:knife][:aws_ssh_key_id] = vm_spec['ssh_key']
122
122
  Chef::Config[:knife][:image] = vm_spec['ami']
123
123
  Chef::Config[:knife][:region] = vm_spec['region']
124
124
  ec2_server_request.config[:image] = vm_spec['ami']
125
125
  ec2_server_request.config[:region] = vm_spec['region']
126
126
  ec2_server_request.config[:chef_node_name] = full_node_name
127
- ec2_server_request.config[:run_list] = node_spec['run_list']
127
+ ec2_server_request.config[:run_list] = node_spec['run_list']
128
128
  ec2_server_request.config[:flavor] = vm_spec['type']
129
129
  ec2_server_request.config[:security_groups] = security_groups if security_groups
130
130
  ec2_server_request.config[:security_group_ids] = security_group_ids if security_group_ids
@@ -136,17 +136,18 @@ class NodefuCreate < Chef::Knife
136
136
  ec2_server_request.config[:distro] = vm_spec['bootstrap']
137
137
  ec2_server_request.config[:server_connect_attribute] = node_spec['server_connect_attribute'] if node_spec['server_connect_attribute']
138
138
  ec2_server_request.config[:environment] = Chef::Config[:environment]
139
+ ec2_server_request.config[:ssh_port] = "22"
139
140
  threads << Thread.new(full_node_name,ec2_server_request) do |full_node_name,request|
140
141
  e = nil
141
- begin
142
+ begin
142
143
  request.run
143
- rescue => e
144
+ rescue => e
144
145
  config[:exit_on_fail] ? raise(e) : puts("#{full_node_name}: #{e.message}")
145
- end
146
+ end
146
147
  sema.synchronize {
147
148
  [full_node_name, { 'server' => request.server, 'failure' => e, 'chef_node' => nil} ]
148
149
  }
149
- end
150
+ end
150
151
  end
151
152
  threads.each(&:join)
152
153
 
@@ -154,17 +155,17 @@ class NodefuCreate < Chef::Knife
154
155
  @servers = threads.inject({}) {|hash,t| hash[t.value[0]] = t.value[1]; hash}
155
156
 
156
157
  query = Chef::Search::Query.new
157
- query.search('node',"name:#{base_name}*#{env}*") { |n| @servers[n.name]['chef_node'] = n unless @servers[n.name].nil? }
158
+ query.search('node',"name:#{base_name}*#{env}*") { |n| @servers[n.name]['chef_node'] = n unless @servers[n.name].nil? }
158
159
 
159
- ui.msg('')
160
+ ui.msg('')
160
161
 
161
162
  failed = failed_nodes(@servers)
162
163
  unless failed.nil?
163
- failed.each_pair do |k,v|
164
+ failed.each_pair do |k,v|
164
165
  if v['server'].nil?
165
166
  ui.msg("#{k}: #{v['failure']}")
166
167
  else
167
- ui.msg("#{k}: #{v['failure']}, #{v['server'].dns_name}, #{v['server'].id}")
168
+ ui.msg("#{k}: #{v['failure']}, #{v['server'].dns_name}, #{v['server'].id}")
168
169
  end
169
170
  end
170
171
  end
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module Nodefu
3
- VERSION = "0.4.2"
3
+ VERSION = "0.4.3"
4
4
  MAJOR, MINOR, TINY = VERSION.split(',')
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-nodefu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
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-07-22 00:00:00.000000000 Z
12
+ date: 2013-09-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: knife-ec2