Issue #16971 has been updated by Henrik Lindberg.

Priority changed from Normal to Low
Target version deleted (3.x)
Affected Puppet version deleted (2.7.18)

This has nothing to do with metaparameters. The error is a Syntax Error as the 
grammar does not allow +> operator in a regular resource definition, only in 
resource overrides. As a workaround it should be possible to first create the 
resource, and then override it.

i.e: try
<pre>
Package {
    require => File['/etc/apt/apt.conf.d/no-cache'],
}
package { 'php5-cli':
    ensure  => present,
}
Package['php5-cli'] {
    require +> Package['php5-cgi'],
}
</pre>

I.e. it works as intended, so this is a feature request to allow +> to append 
to default values. (As the title of the issue says :))

To implement support for this requires:

* grammar change (trivial, do not think this leads to any ambiguities)
* resource instantiation - this is complicated because the defaults are set 
**after** instantiation and the functionality is not in one isolated place.
   * it is in interaction between the three(?) different representations of 
"resource" Type, and the Compiler's scope (which is responsible for actually 
performing the override.
   * Hard to assess how much work this is without actually trying. 
   * The obvious thing to do would be to set the default values first, then let 
other assignments override (or append), but there seems to be other reasons for 
not setting default values early (this to optimize what goes over the wire; 
since default values are not included, not sure yet if they are compared 
against the defaults, or if a check is made if they are absent at that point). 
   * Also very difficult to find if there is any other logic that depends on 
absent default values (any logic that looks up parameters with this 
expectation).
   * If setting defaults first is not an option, then first skipping +> params 
in the normal instantiation and then applying a default and finally a +> may 
work.
   * A more messy alternative is to rip out the +> parameter settings on 
assignment and let the normal instantiation take place, then apply the +>. I.e. 
automatically do what the workaround does by generating an AST tree that does 
just that. 
* Modify existing tests (unknown impact, did not check)
* Write new tests

So, medium sized effort (a couple of days to figure out best approach, 
implement, and test). 

IMO, this is a useful syntactical sugar, but not very important. I would rather 
add this after cleaning up the entire DSL -> Catalog implementation. Marking 
priority as low (works as intended, can be done a different way, no votes). 
Removed affected versions 2.7.18 (works as intended everywhere) and target 
version.


----------------------------------------
Bug #16971: Add values to default resources with the plusignment
https://projects.puppetlabs.com/issues/16971#change-77664

Author: Julien Vaubourg
Status: Accepted
Priority: Low
Assignee: Henrik Lindberg
Category: language
Target version: 
Affected Puppet version: 
Keywords: backlog
Branch: 


# Example #

Directly in site.pp:

    Package {
        require => File['/etc/apt/apt.conf.d/no-cache'],
    }

In the "blog" class:

    package { 'php5-cli':
        ensure  => present,
        require => Package['php5-cgi'],
    }

On the agent side, with the "*require => Package['php5-cgi']*" line:

    # puppet agent -t --noop -d | grep no-cache | grep -i blog
    #

Without it:

    # puppet agent -t --noop -d | grep no-cache | grep -i blog
    debug: /Stage[main]/Blog/Package[php5-cli]/require: requires 
File[/etc/apt/apt.conf.d/no-cache]
    #

And with "*require +> Package['php5-cgi']*":

    # puppet agent -t --noop -d | grep no-cache | grep -i blog
    err: Could not retrieve catalog from remote server: Error 400 on SERVER: 
Syntax error at '+>'; expected '}' at 
/etc/puppet/modules/blog/manifests/init.pp:5 on node xxxxx
    warning: Not using cache on failed catalog
    err: Could not retrieve catalog; skipping run

# Problem #

According to this example:

1. Define a resource set before as a default resource overwrite it.
1. The usage of the plusignment ("*+>*") operator is not recognized in this 
case.

How add values to default resources? The plusignment should work in this case.


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to