diff --git a/lib/puppet/resource/type.rb b/lib/puppet/resource/type.rb index 24ba6416d20..cc4aabc5f7f 100644 --- a/lib/puppet/resource/type.rb +++ b/lib/puppet/resource/type.rb @@ -196,7 +196,7 @@ def instantiate_resource(scope, resource) def name if type == :node && name_is_regex? - "__node_regexp__#{@name.source.downcase.gsub(/[^-\w:.]/, '').sub(/^\.+/, '')}" + "__node_regexp__#{@name.source.downcase.gsub(/[^-\w:.]/, '').sub(/^\.+/, '')}__#{@name.object_id}" else @name end diff --git a/spec/integration/parser/node_spec.rb b/spec/integration/parser/node_spec.rb index 998a6bded9d..3b8062e7daf 100644 --- a/spec/integration/parser/node_spec.rb +++ b/spec/integration/parser/node_spec.rb @@ -85,13 +85,13 @@ class foo { end.not_to raise_error end - it 'errors when two nodes with regexes collide after some regex syntax is removed' do + it 'do not raise an error when two nodes with regexes collide after some regex syntax is removed' do expect do compile_to_catalog(<<-MANIFEST) node /a.*(c)?/ { } node /a.*c/ { } MANIFEST - end.to raise_error(Puppet::Error, /Node '__node_regexp__a.c' is already defined/) + end.not_to raise_error end it 'provides captures from the regex in the node body' do diff --git a/spec/unit/resource/type_spec.rb b/spec/unit/resource/type_spec.rb index 7120b447ff1..01e3e1424e9 100644 --- a/spec/unit/resource/type_spec.rb +++ b/spec/unit/resource/type_spec.rb @@ -60,11 +60,11 @@ end it "should return the regex converted to a string when asked for its name" do - expect(Puppet::Resource::Type.new(:node, /ww/).name).to eq("__node_regexp__ww") + expect(Puppet::Resource::Type.new(:node, /ww/).name).to match(/__node_regexp__ww__\d+/) end it "should downcase the regex when returning the name as a string" do - expect(Puppet::Resource::Type.new(:node, /W/).name).to eq("__node_regexp__w") + expect(Puppet::Resource::Type.new(:node, /W/).name).to match(/__node_regexp__w__\d+/) end it "should remove non-alpha characters when returning the name as a string" do