Greetings.
I''m curious if their are any magic variable builtins that one can
use in situations like the following.
In the following example the file element name is
"solaris_media_locations". I have that same filename in the path and
content values. Is their any shorthand way to reuse the element
name?
file { "solaris_media_locations":
path => "/opt/SUNWjet/etc/solaris_media_locations",
content =>
template("jumpstart/solaris_media_locations.erb"),
require => File[SUNWjet],
}
For example something like this
file { "solaris_media_locations":
path => "/opt/SUNWjet/etc/$element_name",
content => template("jumpstart/$element_name.erb"),
require => File[SUNWjet],
}
I''ve survived my first 6 weeks with puppet using the syntax in the
first example and it''s not really a big deal. As I''m getting
more
and more comfortable I''m just wondering if their are "better"
ways for
some of my manifest markups.
Thanks. Derek.
--
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.
deet wrote:> Greetings. > > I''m curious if their are any magic variable builtins that one can > use in situations like the following. > > In the following example the file element name is > "solaris_media_locations". I have that same filename in the path and > content values. Is their any shorthand way to reuse the element > name? >First, it''s called a resource :) To answer your question: Yes, you can. You''re looking for either the $name or $title variable (by default they are both the same). But you''ll have to wrap the resource in a define - I don''t know of a way to use these variables in a resource directly. -scott -- 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.
> To answer your question: Yes, you can. You''re looking for either the $name or $title variable (by > default they are both the same). >Thanks Scott. Sounds like I''ll stick with what I''m doing as it seems the defines won''t save me much work. Thanks again for the quick reply. Happy Holidays. Derek.> But you''ll have to wrap the resource in a define - I don''t know of a way to use these variables in a > resource directly. > > -scott-- 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.
deet wrote:> Thanks Scott. > Sounds like I''ll stick with what I''m doing as it seems the defines > won''t save me much work. > Thanks again for the quick reply. >You could do: define solaris::media($ensure = "present") { file { "solaris_media_${name}": path => "/opt/SUNWjet/etc/$name", content => template("jumpstart/${name}.erb"), ensure => $ensure, require => File[SUNWjet] # don''t you mean Package[SUNWjet] ? } } ... $media_locs = [ "foo", "bar" ] solaris::media { $media_locs: ensure => present } Not too much work. -scott -- 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.
> You could do: > > define solaris::media($ensure = "present") { > file { "solaris_media_${name}": > path => "/opt/SUNWjet/etc/$name", > content => template("jumpstart/${name}.erb"), > ensure => $ensure, > require => File[SUNWjet] # don''t you mean Package[SUNWjet] ? > } >Ok. I misunderstood how it would work initially. Your example is very helpful and I have a few places to try this out. WRT to JET. My installation first adds the SUNWjet (and related) packages and then my custom modules, scripts, templates get pulled from a directory called SUNWjet. Thanks. Derek.> }> -scott-- 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.