Hi, I''m trying to get the following to work: class cluster { $cluster_name = hostname.slice(0..-2) . . } # class hoping that if I have a server called appfarmserver1 (obtained from facter, can I use a fact like this!?), cluster_name will get set to appfarmserver . . . puppet --parseonly init.pp says: err: Could not parse for environment production: Syntax error at ''.''; expected ''}'' Is there some way to get this to work? Is there a better, more puppetty way to do what I want to do, i.e. based on the hostname from fatcer, set the variable cluster_name for use in a template. Thanks so much, Guy Matz -- 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.
Jacob Helwig
2011-Jun-16 16:03 UTC
Re: [Puppet Users] is ruby code allowed in puppet manifest?
On Thu, 16 Jun 2011 11:56:59 -0400, Guy Matz wrote:> > Hi, > I''m trying to get the following to work: > > class cluster { > > $cluster_name = hostname.slice(0..-2) > . > . > } # class > > hoping that if I have a server called appfarmserver1 (obtained from facter, > can I use a fact like this!?), cluster_name will get set to appfarmserver . > . . > > puppet --parseonly init.pp says: > err: Could not parse for environment production: Syntax error at ''.''; > expected ''}'' > > Is there some way to get this to work? Is there a better, more puppetty way > to do what I want to do, i.e. based on the hostname from fatcer, set the > variable cluster_name for use in a template. > > Thanks so much, > Guy Matz >The most "puppety" way to do it is to create a custom fact that will return this for you, instead of doing it in the manifest. You could do it in the manifest using an inline ERB template, but it''s rather hacky. I definitely recommend going the custom fact route instead. -- Jacob Helwig
Aaron Grewell
2011-Jun-16 16:12 UTC
Re: [Puppet Users] is ruby code allowed in puppet manifest?
You have the choice of either a Puppet DSL manifest or a Ruby DSL manifest. You cannot mix the two within a single file. On Thu, Jun 16, 2011 at 8:56 AM, Guy Matz <gmatz@matz.org> wrote:> Hi, > I''m trying to get the following to work: > > class cluster { > > $cluster_name = hostname.slice(0..-2) > . > . > } # class > > hoping that if I have a server called appfarmserver1 (obtained from facter, > can I use a fact like this!?), cluster_name will get set to appfarmserver . > . . > > puppet --parseonly init.pp says: > err: Could not parse for environment production: Syntax error at ''.''; > expected ''}'' > > Is there some way to get this to work? Is there a better, more puppetty > way to do what I want to do, i.e. based on the hostname from fatcer, set the > variable cluster_name for use in a template. > > Thanks so much, > Guy Matz > > > -- > 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 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.