Chris de Villiers
2011-Jul-01 07:48 UTC
[Puppet Users] Override resource in nested class structure
Hello everybody
I have a set of nested classes and the deepest class looks after a
file resource. I want all my nodes to be of the parent class type
except one of them needs a special copy of the same file resource.
How do I override the file resource for that specific node without
copying the entire class hierarchy for just that one node? Example:
class { ''a'':
include b
...
}
class { ''b'':
include c
...
}
class { ''c'':
file { ''foo'':
ensure => file,
source => ''puppet:///modules/...'',
}
}
node default {
include a
}
node ''specialnode'' {
include a
# OVERRIDE FILE RESOURCE ''foo'' HERE!!
}
I want ''specialnode'' to have it''s own file
''foo'' resource which
differs from the one in class ''c''.
Thank you!
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to
puppet-users+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.
vagn scott
2011-Jul-02 00:04 UTC
Re: [Puppet Users] Override resource in nested class structure
Here''s one way. It''s ugly, but it works.
--
vagn
#! /usr/bin/puppet apply
# Hello everybody
#
# I have a set of nested classes and the deepest class looks after a
# file resource. I want all my nodes to be of the parent class type
# except one of them needs a special copy of the same file resource.
# How do I override the file resource for that specific node without
# copying the entire class hierarchy for just that one node? Example:
$default = "/tmp/foo"
define a($filename = "$default") {
b { "b from a": filename => "$filename" }
#...
}
define b($filename = "$default") {
c { "c from b": filename => "$filename" }
#...
}
define c($filename = "$default") {
file { "$filename":
ensure => file,
content => "filename: $filename\n",
}
notice("title = $title, filename = $filename\n")
}
node default {
a { "a from default": }
}
node ''specialnode'' {
a { "a from specialnode": filename => "/tmp/baz" }
}
# I want ''specialnode'' to have it''s own file
''foo'' resource which
# differs from the one in class ''c''.
#
# Thank you!
On 07/01/2011 03:48 AM, Chris de Villiers wrote:> Hello everybody
>
> I have a set of nested classes and the deepest class looks after a
> file resource. I want all my nodes to be of the parent class type
> except one of them needs a special copy of the same file resource.
> How do I override the file resource for that specific node without
> copying the entire class hierarchy for just that one node? Example:
>
> class { ''a'':
> include b
> ...
> }
>
> class { ''b'':
> include c
> ...
> }
>
> class { ''c'':
> file { ''foo'':
> ensure => file,
> source => ''puppet:///modules/...'',
> }
> }
>
> node default {
> include a
> }
>
> node ''specialnode'' {
> include a
> # OVERRIDE FILE RESOURCE ''foo'' HERE!!
> }
>
> I want ''specialnode'' to have it''s own file
''foo'' resource which
> differs from the one in class ''c''.
>
> Thank you!
>
>
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to
puppet-users+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.