diff --git a/lib/puppet/provider/node_group/https.rb b/lib/puppet/provider/node_group/https.rb index ccf8e36..439ca2f 100644 --- a/lib/puppet/provider/node_group/https.rb +++ b/lib/puppet/provider/node_group/https.rb @@ -137,6 +137,11 @@ def parent gindex = $ngs.index { |i| i['name'] == value } @property_flush['attrs'][property.to_s] = $ngs[gindex]['id'] end + # These 2 attributes are additive, so need to submit nulls to remove unwanted values + elsif [:variables, :classes].include?(property) + @property_flush['attrs'][property.to_s] = add_nulls(@property_hash[property], value) + # For logging return to original intended value + @resource[property] = value.select { |k,v| v != nil } else # The to_json function needs to recognize # booleans true/false, not symbols :true/false @@ -172,4 +177,11 @@ def get_id_index_from_name(name) $ngs.index { |i| i['name'] == name } end + def add_nulls(current, new) + difference = current.keys - new.keys + nullhash = new + difference.each { |k| nullhash[k] = nil } + nullhash + end + end diff --git a/lib/puppet/provider/node_group/puppetclassify.rb b/lib/puppet/provider/node_group/puppetclassify.rb index f9a364c..6610567 100644 --- a/lib/puppet/provider/node_group/puppetclassify.rb +++ b/lib/puppet/provider/node_group/puppetclassify.rb @@ -148,6 +148,11 @@ def parent gindex = $ngs.index { |i| i['name'] == value } @property_flush['attrs'][property.to_s] = $ngs[gindex]['id'] end + # These 2 attributes are additive, so need to submit nulls to remove unwanted values + elsif [:variables, :classes].include?(property) + @property_flush['attrs'][property.to_s] = add_nulls(@property_hash[property], value) + # For logging return to original intended value + @resource[property] = value.select { |k,v| v != nil } else # The to_json function needs to recognize # booleans true/false, not symbols :true/false @@ -189,4 +194,11 @@ def get_id_index_from_name(name) $ngs.index { |i| i['name'] == name } end + def add_nulls(current, new) + difference = current.keys - new.keys + nullhash = new + difference.each { |k| nullhash[k] = nil } + nullhash + end + end