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

Context sensitive directives report duplicate resource definitions #1

Closed
jcpunk opened this issue Apr 7, 2015 · 2 comments
Closed
Labels
enhancement New feature or request

Comments

@jcpunk
Copy link

jcpunk commented Apr 7, 2015

Consider the following puppet code:

apache_directive { 'Disable autoindex in webroot':
  ensure      => present,
  name        => 'Options',
  context     => 'Directory[arg="/var/www/html"]',
  args        => 'FollowSymLinks',
}

apache_directive { 'Disable autoindex in icons':
  ensure      => present,
  name        => 'Options',
  context     => 'Directory[arg="/var/www/icons"]',
  args        => 'MultiViews FollowSymLinks',
}

When imported into a node these items report the following error:
Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Cannot alias Apache_directive[Disable autoindex in icons] to ["Options"] at test.pp:19; resource ["Apache_directive", "Options"] already declared at test.pp:12 at test.pp:19 on node hostname.example.com

@raphink
Copy link
Member

raphink commented Apr 7, 2015

Given the Puppet code you list, it is expected that you would get a duplicate resource.

What is required here is a composite namevar, like we already have in the pg_hba provider for example.

Ideally, this namevar would take the name, context and target parameters into play, so you can write:

apache_directive { 'Options of Directory[arg="/var/www/html"]':
  ensure      => present,
  args        => 'FollowSymLinks',
}

apache_directive { 'Options of Directory[arg="/var/www/icons"]':
  ensure      => present,
  args        => 'MultiViews FollowSymLinks',
}

See also this PR for another example of composite namevar implementation.

@raphink raphink added the enhancement New feature or request label Apr 7, 2015
@jcpunk
Copy link
Author

jcpunk commented Apr 13, 2015

Closing issue, moving to #2

@jcpunk jcpunk closed this as completed Apr 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants