Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple consul::service with same name causes ArgumentError #46

Closed
jsok opened this issue Nov 12, 2014 · 4 comments
Closed

Multiple consul::service with same name causes ArgumentError #46

jsok opened this issue Nov 12, 2014 · 4 comments

Comments

@jsok
Copy link
Contributor

jsok commented Nov 12, 2014

I need to create multiple services with the same name (but unique ID) on the same agent, e.g. a service definition like:

{
  "service": {
    "name": "gateway",
    "id": "foo"
  }
}

{
  "service": {
    "name": "gateway",
    "id": "bar"
  }
}

So I created the resources:

consul::service { 'foo':
  name => 'gateway',
}

consul::service { 'bar':
  name => 'gateway',
}

And puppet (2.7) is failing with:

Puppet::Parser::AST::Resource failed with error ArgumentError: Cannot alias Consul::Service[bar] to ["gateway"] at /etc/puppet/roles/app/manifests/gateway.pp:10; resource ["Consul::Service", "gateway"] already defined at /etc/puppet/roles/app/manifests/gateway.pp:10 at /etc/puppet/roles/app/manifests/gateway.pp:10 on node ip-xx-xx-xx-xx.ec2.internal
@solarkennedy
Copy link
Contributor

Puppet does not allow duplicate resources to have the same name.

What if you did a PR that had a variable called "$service_name", which could still default to "$name" but would allow you to still set it?

@jsok
Copy link
Contributor Author

jsok commented Nov 12, 2014

Yep that's the exact fix I was about to PR :)

@EvanKrall
Copy link
Contributor

:( you're right: https://docs.puppetlabs.com/puppet/latest/reference/lang_resources.html#uniqueness

I thought when I wrote this code that only $title had to be unique.

@solarkennedy
Copy link
Contributor

Yea I... also thought that it was just title. But I still get confused on the title/name distinction too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants