resource title is unique for each instance. what about resource name?

65 views
Skip to first unread message

David Portabella

unread,
Mar 31, 2014, 9:14:18 AM3/31/14
to puppet...@googlegroups.com
resource title is guaranteed to be unique for each instance.

I thought that resource name was not required to be unique.
however this code suggests the opposite:

my_resource { r1:
  name => 'r'
}

my_resource { r2:
  name => 'r'
}

define my_resource {
}

$ puppet apply test.pp
Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Cannot alias My_resource[r2] to ["r"] at /private/tmp/a.pp:7; resource ["My_resource", "r"] already declared at /private/tmp/a.pp:3 at /private/tmp/a.pp:7 on node mac4c.local


so, is resource name also unique for each instance?

where is it explained?


Craig Dunn

unread,
Mar 31, 2014, 10:00:30 AM3/31/14
to puppet...@googlegroups.com

The resource title and namevar must be unique for any resource as documented here...

http://docs.puppetlabs.com/puppet/latest/reference/lang_resources.html#uniqueness

Defined resource types follow the same rules and the $name variable is always assumed to be a namevar.

Craig




--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/6504c812-6f10-4955-8907-b29c0ac71d07%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Enviatics | Automation and configuration management
http://www.enviatics.com | @Enviatics
Puppet Training http://www.enviatics.com/training/

David Portabella

unread,
Mar 31, 2014, 11:33:04 AM3/31/14
to puppet...@googlegroups.com
great, thanks!
Reply all
Reply to author
Forward
0 new messages