hazetug 0.1.2 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 232620443790901644f47f44c1904f61f3ce8733
4
- data.tar.gz: 9221b8cb51f1ff8175b9c8c5ab07ab5cc029ec2b
3
+ metadata.gz: 723a5d37ca91b5fde0e80ec539e3d6a94c1acfdf
4
+ data.tar.gz: 8a73f894d14f9c9a91387e0cde7fa1027d7b5a57
5
5
  SHA512:
6
- metadata.gz: 2e83f628063452264ff041902d822651060d066f468b65efaa3f949a8a35a0e2f6680111445731310ea20a326ba670b134fdcc9c9db7f430612067435dbe7a0f
7
- data.tar.gz: d7b0c52a0c92af20398be2af7d08e213a380d1d1d5d9c82e6d955fc39a1d93c9ca70f56332edbdf3aa794fbf4022b5a68c2603e3bdb5e2458bc966e02fdcceaf
6
+ metadata.gz: 5c3e424bc320a7c7d0fd03fc3ddb882e32b0b265ff682b5960a726c5c079f303d9afd9c67cb810ffe2ce82a8ccdbace8df7de95259c2a6bc2ab896a8cc62ca14
7
+ data.tar.gz: 7992188b72be3ea5a17224c443ba7ad71806b5736f37ab06c75d56af9c0b9f2749ee781f03c6a37be0287bbad179606d545d9ae86dfda64456c5fc503b7daf43
@@ -43,30 +43,35 @@ class Hazetug
43
43
 
44
44
  def bootstrap_list(&block)
45
45
  return if block.nil?
46
- task.hosts_to_bootstrap(env_split) do |conf|
47
- num = conf[:number] || data[:opts][:number].to_i || 1
46
+ task.hosts_to_bootstrap(command_variables) do |conf|
47
+
48
48
  if convert_rand_name(conf[:name]) == conf[:name] && num > 1
49
49
  ui.fatal "Can't bootstrap several hosts with the same name"
50
50
  raise ArgumentError, "%rand(x)% expected"
51
51
  end
52
+
53
+ num = conf[:number] || data[:opts][:number].to_i || 1
52
54
  (1..num).each do
53
55
  newconf = conf.dup
54
56
  newconf[:name] = convert_rand_name(conf[:name])
57
+
55
58
  haze = Hazetug::Haze[data[:compute_name]].new(newconf)
56
- # Ensure a dynamic password loaded back from haze
59
+
57
60
  if haze.config[:ssh_password]
61
+ # Ensure a dynamic password loaded back from haze
58
62
  newconf[:ssh_password] = haze.config[:ssh_password]
59
63
  end
64
+
60
65
  tug = Hazetug::Tug[data[:tug_name]].new(newconf, haze)
61
66
  block.call(haze, tug)
62
67
  end
63
68
  end
64
69
  end
65
70
 
66
- def env_split
67
- @env_split ||= begin
71
+ def command_variables
72
+ @command_variables ||= begin
68
73
  env = {}
69
- arr = data[:opts][:env]
74
+ arr = data[:opts][:variables]
70
75
  if arr
71
76
  arr.each do |eq|
72
77
  k, v = eq.split('=')
@@ -19,7 +19,8 @@ class Hazetug
19
19
  def create_server_args
20
20
  latest = /^Latest #{config[:bits]} bit/
21
21
  {
22
- :name => config[:name],
22
+ # linode node name can't contain dots
23
+ :name => config[:name].gsub(/./,'-'),
23
24
  :data_center => lookup(:location),
24
25
  :flavor => lookup(:flavor),
25
26
  :image => lookup(:image),
data/lib/hazetug/task.rb CHANGED
@@ -23,11 +23,11 @@ class Hazetug
23
23
  @task[key]
24
24
  end
25
25
 
26
- def hosts_to_bootstrap(env={}, &block)
26
+ def hosts_to_bootstrap(cmd_vars={}, &block)
27
27
  return if block.nil?
28
28
  base_conf = Mash.new(task)
29
29
  hosts = base_conf.delete(:bootstrap)
30
- base_conf = Chef::Mixin::DeepMerge.merge(base_conf, env)
30
+ base_conf = Chef::Mixin::DeepMerge.merge(base_conf, cmd_vars)
31
31
  hosts.each do |conf|
32
32
  merged = Chef::Mixin::DeepMerge.merge(base_conf, conf)
33
33
  block.call(merged)
@@ -48,7 +48,9 @@ class Hazetug
48
48
  end
49
49
  kb.name_args = [haze.server.ssh_ip_address]
50
50
  kb.run
51
- ensure
51
+ rescue Hazetug::Exception => e
52
+ ui.error(e.message); 1
53
+ ensure
52
54
  @kb and @kb.ui.stdout.close
53
55
  end
54
56
 
@@ -65,10 +67,17 @@ class Hazetug
65
67
 
66
68
  def bootstrap_options
67
69
  @bootstrap_options ||= begin
68
- template = options[:opts][:bootstrap]
70
+ template = options[:opts][:bootstrap] || 'bootstrap.erb'
71
+ validation = config[:chef_validation_key] || 'validation.pem'
72
+
73
+ files = [template, validation].map {|f| File.expand_path(f)}
74
+ notfound = files.select {|f| !File.exist?(f)}
75
+ notfound.empty? or
76
+ raise Hazetug::Exception, "File(s) not found: #{notfound.join(', ')}"
77
+
69
78
  opts = {}
70
- opts[:validation_key] = File.expand_path(config[:chef_validation_key] || 'validation.pem')
71
- opts[:template_file] = File.expand_path(template || 'bootstrap.erb')
79
+ opts[:validation_key] = File.expand_path(validation)
80
+ opts[:template_file] = File.expand_path(template)
72
81
  opts[:ssh_user] = config[:ssh_user] || 'root'
73
82
  opts[:ssh_password] = config[:ssh_password]
74
83
  opts[:environment] = config[:chef_environment]
@@ -1,3 +1,3 @@
1
1
  class Hazetug
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hazetug
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Barishev