kondate 0.3.0 → 0.3.1

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: cee86599c07e6b8ab7d455f0547e1332be08ce04
4
- data.tar.gz: 644a9d48e73a01679e55bec6fae04d8d074b2cb2
3
+ metadata.gz: 84fbadf47b428eeb9842d1676c064afc8f747d0c
4
+ data.tar.gz: deffef184f5a2739801fd486722a9d103a4999c1
5
5
  SHA512:
6
- metadata.gz: 330c1056afd6e8ee5723d61f1bacd39bb65357b37f5a44c37be195b16ea5775d3110f23661e06fb5f0386abab07e3f99baefd6f9b97f913cfa598fc67203c6bf
7
- data.tar.gz: f832e67244d4326b7cbc381f66062a4ca0f27b9755683a24ea7c879f585608404ce2bd4a3b7c938a2baa7fd23455fa6513dc419c75efef092d439a17a73438e7
6
+ metadata.gz: 4c03b7ca0525454cdb06a014cc66a315beba424eb40b9dacd97d021bdae42406ab1206418f61414d566c23116c60588d7fddef6f4cc44c2192cb579fa27bbb01
7
+ data.tar.gz: 0543bde5cf1b8a5d08906c701017655a58665e0c2a4a98fbb4aea843d3f9a6fc7f037c8180dd9351e54c50346362416db8fbfe0b3f973f65e2518256755eeada
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # 0.3.1 (2016-11-18)
2
+
3
+ Fixes:
4
+
5
+ * Fix to remove temporary property files properly
6
+
1
7
  # 0.3.0 (2016-11-18)
2
8
 
3
9
  Enhancements:
data/lib/kondate/cli.rb CHANGED
@@ -57,8 +57,12 @@ module Kondate
57
57
  option :recipe_graph, :type => :string, :default => nil, :desc => "[EXPERIMENTAL] Write recipe dependency graph in DOT", :banner => "PATH"
58
58
  def itamae(host)
59
59
  property_files = build_property_files(host)
60
- if proceed?(property_files)
61
- exit(-1) unless do_itamae(host, property_files)
60
+ begin
61
+ if proceed?(property_files)
62
+ exit(-1) unless do_itamae(host, property_files)
63
+ end
64
+ ensure
65
+ clean_property_files(property_files)
62
66
  end
63
67
  end
64
68
 
@@ -81,11 +85,15 @@ module Kondate
81
85
  $stdout.puts "Target hosts are [#{hosts.join(", ")}]"
82
86
 
83
87
  property_files_of_hosts, summarized_property_files, hosts_of_roles = build_property_files_of_hosts(hosts)
84
- if proceed?(summarized_property_files, hosts_of_roles)
85
- successes = Parallel.map(hosts, in_processes: @options[:parallel]) do |host|
86
- do_itamae(host, property_files_of_hosts[host])
88
+ begin
89
+ if proceed?(summarized_property_files, hosts_of_roles)
90
+ successes = Parallel.map(hosts, in_processes: @options[:parallel]) do |host|
91
+ do_itamae(host, property_files_of_hosts[host])
92
+ end
93
+ exit(-1) unless successes.all?
87
94
  end
88
- exit(-1) unless successes.all?
95
+ ensure
96
+ clean_property_files_of_hosts(property_files_of_hosts)
89
97
  end
90
98
  end
91
99
 
@@ -97,8 +105,12 @@ module Kondate
97
105
  option :vagrant, :type => :boolean, :default => false
98
106
  def serverspec(host)
99
107
  property_files = build_property_files(host)
100
- if proceed?(property_files)
101
- exit(-1) unless do_serverspec(host, property_files)
108
+ begin
109
+ if proceed?(property_files)
110
+ exit(-1) unless do_serverspec(host, property_files)
111
+ end
112
+ ensure
113
+ clean_property_files(property_files)
102
114
  end
103
115
  end
104
116
 
@@ -119,11 +131,15 @@ module Kondate
119
131
  $stdout.puts "Target hosts are [#{hosts.join(", ")}]"
120
132
 
121
133
  property_files_of_hosts, summarized_property_files, hosts_of_roles = build_property_files_of_hosts(hosts)
122
- if proceed?(summarized_property_files, hosts_of_roles)
123
- successes = Parallel.map(hosts, in_processes: @options[:parallel]) do |host|
124
- do_serverspec(host, property_files_of_hosts[host])
134
+ begin
135
+ if proceed?(summarized_property_files, hosts_of_roles)
136
+ successes = Parallel.map(hosts, in_processes: @options[:parallel]) do |host|
137
+ do_serverspec(host, property_files_of_hosts[host])
138
+ end
139
+ exit(-1) unless successes.all?
125
140
  end
126
- exit(-1) unless successes.all?
141
+ ensure
142
+ clean_property_files_of_hosts(property_files_of_hosts)
127
143
  end
128
144
  end
129
145
 
@@ -217,6 +233,18 @@ module Kondate
217
233
  end
218
234
  end
219
235
 
236
+ def clean_property_files(property_files)
237
+ property_files.values.each do |file|
238
+ File.unlink(file) rescue nil
239
+ end
240
+ end
241
+
242
+ def clean_property_files_of_hosts(property_files_of_hosts)
243
+ property_files_of_hosts.values.each do |property_files|
244
+ clean_property_files(property_files)
245
+ end
246
+ end
247
+
220
248
  # @return [Hash] key value pairs whoses keys are roles and values are path (or nil)
221
249
  def build_property_files(host)
222
250
  builder = PropertyBuilder.new(host)
@@ -136,10 +136,10 @@ module Kondate
136
136
  if property['attributes'].empty?
137
137
  nil
138
138
  else
139
- fp = Tempfile.open("kondate_")
139
+ fp = Tempfile.create("kondate_")
140
140
  YAML.dump(property, fp)
141
141
  fp.close
142
- fp.path # should be removed when process finishes
142
+ fp.path
143
143
  end
144
144
  end
145
145
  end
@@ -1,3 +1,3 @@
1
1
  module Kondate
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kondate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - sonots