@@ -34,6 +34,7 @@ def self.friendly_name
3434 :rule => 'rule' ,
3535 :variables => 'variables' ,
3636 :description => 'description' ,
37+ :config_data => 'data' ,
3738 }
3839 end
3940
@@ -82,6 +83,7 @@ def create
8283 key = k . to_s
8384 # key changed for usability
8485 key = 'environment_trumps' if key == 'override_environment'
86+ key = 'config_data' if key == 'data'
8587 send_data [ key ] = v
8688 end
8789 # namevar may not be in this hash
@@ -135,6 +137,11 @@ def classes
135137 PuppetX ::Node_manager ::Common . sort_hash ( @property_hash [ :classes ] )
136138 end
137139
140+ def data
141+ # Need to deep sort hashes so they be evaluated equally
142+ PuppetX ::Node_manager ::Common . sort_hash ( @property_hash [ :data ] )
143+ end
144+
138145 def rule
139146 @property_hash [ :rule ] . nil? ? [ '' ] : @property_hash [ :rule ]
140147 end
@@ -148,11 +155,11 @@ def rule
148155 gindex = $ngs. index { |i | i [ 'name' ] == value }
149156 @property_flush [ 'attrs' ] [ property . to_s ] = $ngs[ gindex ] [ 'id' ]
150157 end
151- # These 2 attributes are additive, so need to submit nulls to remove unwanted values
152- elsif [ :variables , :classes ] . include? ( property )
153- @property_flush [ 'attrs' ] [ property . to_s ] = add_nulls ( @property_hash [ property ] , value )
158+ # These 3 attributes are additive, so need to submit nulls to remove unwanted values
159+ elsif [ :variables , :classes , :config_data ] . include? ( property )
160+ @property_flush [ 'attrs' ] [ property . to_s ] = add_nulls ( @property_hash [ friendly . to_sym ] , value )
154161 # For logging return to original intended value
155- @resource [ property ] = value . select { |k , v | v != nil }
162+ @resource [ friendly . to_sym ] = value . select { |k , v | v != nil }
156163 else
157164 # The to_json function needs to recognize
158165 # booleans true/false, not symbols :true/false
@@ -198,7 +205,9 @@ def add_nulls(current, new)
198205
199206 allkeys . each do |k |
200207 if new [ k ] . is_a? ( Hash )
201- newhash [ k ] = add_nulls ( current [ k ] , new [ k ] )
208+ # Push forward an empty hash if nothing is there
209+ _current = current . is_a? ( Hash ) ? current [ k ] : { }
210+ newhash [ k ] = add_nulls ( _current , new [ k ] )
202211 else
203212 newhash [ k ] = new [ k ] || nil
204213 end
0 commit comments