summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/grammar.ra
diff options
context:
space:
mode:
authorBrice Figureau <brice-puppet@daysofwonder.com>2008-10-11 17:26:50 +0200
committerJames Turnbull <james@lovedthanlost.net>2009-03-14 11:31:28 +1100
commitb15028f55ba608a701efae1ee392d50374b2be54 (patch)
treebf4c4053dcc797c1bef3b89cf634bdd3b2828d3f /lib/puppet/parser/grammar.ra
parentb24b9f5de02f4dfc6a7e89d5432aec32ea39cae1 (diff)
downloadpuppet-b15028f55ba608a701efae1ee392d50374b2be54.tar.gz
puppet-b15028f55ba608a701efae1ee392d50374b2be54.tar.xz
puppet-b15028f55ba608a701efae1ee392d50374b2be54.zip
Fix #1088 - Collections overrides
This changeset defines a new syntax to override collection of resources (virtual or not). This feature is not constrained to the override in inherited context as usual resource override. The collection of resource supports a query like regular collection of virtual or exported resources. Usage example: file { "/tmp/testing": content => "whatever" } File<| |> { mode => 0600 } It also introduces a different behaviour for collection of catalog resources. Before this patch, only virtual resources were collected, now all resources (virtual or no) are collected and can be overriden. That means it is now possible to do: File <| |> { mode => 0600 } And all the Files resources will have mode 0600. It is then possible to have this puppet pattern: file { "/tmp/a": content => "a" } file { "/tmp/b": content => "b" } File <| title != "/tmp/a" |> { require => File["/tmp/b"] } which means that every File requires a file. Moreover it is now possible to define resource overriding without respecting the override on inheritance rule: class a { file { "/tmp/testing": content => "whatever" } } class b { include a File<| |> { mode => 0600 } } include b Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'lib/puppet/parser/grammar.ra')
-rw-r--r--lib/puppet/parser/grammar.ra22
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/puppet/parser/grammar.ra b/lib/puppet/parser/grammar.ra
index 67303ab46..9da2999df 100644
--- a/lib/puppet/parser/grammar.ra
+++ b/lib/puppet/parser/grammar.ra
@@ -195,7 +195,27 @@ at: AT { result = :virtual }
# A collection statement. Currently supports no arguments at all, but eventually
# will, I assume.
-collection: classref collectrhand {
+collection: classref collectrhand LBRACE anyparams endcomma RBRACE {
+ if val[0] =~ /^[a-z]/
+ Puppet.warning addcontext("Collection names must now be capitalized")
+ end
+ type = val[0].downcase
+ args = {:type => type}
+
+ if val[1].is_a?(AST::CollExpr)
+ args[:query] = val[1]
+ args[:query].type = type
+ args[:form] = args[:query].form
+ else
+ args[:form] = val[1]
+ end
+ if args[:form] == :exported and ! Puppet[:storeconfigs] and ! Puppet[:parseonly]
+ Puppet.warning addcontext("You cannot collect exported resources without storeconfigs being set; the collection will be ignored")
+ end
+ args[:override] = val[3]
+ result = ast AST::Collection, args
+}
+ | classref collectrhand {
if val[0] =~ /^[a-z]/
Puppet.warning addcontext("Collection names must now be capitalized")
end