Hi all,
I am having an issue with the syntax for a node definition. I want to
use a facter variable in my definition but I get a syntax error. Here
is the code
node "${fqdn}" { include adm }
Here is the error.
Could not parse for environment production: Syntax error at
'''';
expected ''}'' at /etc/puppet/manifests/nodes.pp:16
I test to make sure that ${fqdn} is set before defining the node. I
have used static strings and regexes and they all work but, for some
reason, the variable will not be expanded.
Thanks
--
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.
On 12/20/2010 05:23 PM, rjl wrote:> Hi all, > I am having an issue with the syntax for a node definition. I want to > use a facter variable in my definition but I get a syntax error. Here > is the code > > node "${fqdn}" { include adm } > > Here is the error. > > Could not parse for environment production: Syntax error at ''''; > expected ''}'' at /etc/puppet/manifests/nodes.pp:16 > > I test to make sure that ${fqdn} is set before defining the node. I > have used static strings and regexes and they all work but, for some > reason, the variable will not be expanded.Hi, what are you trying to solve? Seeing as this node definition will apply to each and every client, you can as well put that include to the general scope (outside any node). Is that line 16 you posted there? Because that error seems weird to me. Regards, Felix -- 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.
Hi Felix,
Actually, it will not apply to each client. Each of my clients knows
what role it plays. That is set in a facter variable ($osp_type) on
the client. So, the entire code block looks like this...
case $osp_type {
adm: { node "${fqdn}" { include adm } }
ing: { node "${fqdn}" { include ing } }
rep: { node "${fqdn}" { include rep } }
oss: { node "${fqdn}" { include oss } }
mds: { node "${fqdn}" { include mds } }
default: { notice("Could not resolve role for ${fqdn}") }
}
I am applying the appropriate class to apply based on the role.
rjl
On Dec 20, 9:32 am, Felix Frank <felix.fr...@alumni.tu-berlin.de>
wrote:> On 12/20/2010 05:23 PM, rjl wrote:
>
> > Hi all,
> > I am having an issue with the syntax for a node definition. I want to
> > use a facter variable in my definition but I get a syntax error. Here
> > is the code
>
> > node "${fqdn}" { include adm }
>
> > Here is the error.
>
> > Could not parse for environment production: Syntax error at
'''';
> > expected ''}'' at /etc/puppet/manifests/nodes.pp:16
>
> > I test to make sure that ${fqdn} is set before defining the node. I
> > have used static strings and regexes and they all work but, for some
> > reason, the variable will not be expanded.
>
> Hi,
>
> what are you trying to solve? Seeing as this node definition will apply
> to each and every client, you can as well put that include to the
> general scope (outside any node).
>
> Is that line 16 you posted there? Because that error seems weird to me.
>
> Regards,
> Felix
--
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.
On 12/20/2010 05:46 PM, rjl wrote:> Hi Felix, > Actually, it will not apply to each client. Each of my clients knows > what role it plays. That is set in a facter variable ($osp_type) on > the client. So, the entire code block looks like this... > > case $osp_type { > adm: { node "${fqdn}" { include adm } } > ing: { node "${fqdn}" { include ing } } > rep: { node "${fqdn}" { include rep } } > oss: { node "${fqdn}" { include oss } } > mds: { node "${fqdn}" { include mds } } > default: { notice("Could not resolve role for ${fqdn}") } > }Those node declarations are still spurious. Also, I don''t think nodes can be declared in case branches like that, so this is probably the error? Just write case $osp_type { adm: { include adm } ... } HTH, Felix -- 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.
I have take it out of the case statement to try to resolve the
problem. Here is an example. I receive the same error from this...
$tmp = "deving0109.cdntools.nsatc.net"
node "${tmp}" { include adm }
But this works just fine...
node "deving0109.cdntools.nsatc.net" { include adm }
On Dec 20, 9:51 am, Felix Frank <felix.fr...@alumni.tu-berlin.de>
wrote:> On 12/20/2010 05:46 PM, rjl wrote:
>
> > Hi Felix,
> > Actually, it will not apply to each client. Each of my clients knows
> > what role it plays. That is set in a facter variable ($osp_type) on
> > the client. So, the entire code block looks like this...
>
> > case $osp_type {
> > adm: { node "${fqdn}" { include adm } }
> > ing: { node "${fqdn}" { include ing } }
> > rep: { node "${fqdn}" { include rep } }
> > oss: { node "${fqdn}" { include oss } }
> > mds: { node "${fqdn}" { include mds } }
> > default: { notice("Could not resolve role for ${fqdn}") }
> > }
>
> Those node declarations are still spurious. Also, I don''t think
nodes
> can be declared in case branches like that, so this is probably the error?
>
> Just write
>
> case $osp_type {
> adm: { include adm }
> ...
>
> }
>
> HTH,
> Felix
--
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.
On 12/20/2010 05:55 PM, rjl wrote:> I have take it out of the case statement to try to resolve the > problem. Here is an example. I receive the same error from this... > > $tmp = "deving0109.cdntools.nsatc.net" > node "${tmp}" { include adm } > > But this works just fine... > node "deving0109.cdntools.nsatc.net" { include adm }Well, I''m stumped. Maybe variable substition is just not meant to work for node declarations. I still don''t see what you need it for. Your earlier post is a very good depiction of how to choose a node''s role based on a fact: Do it by selecting the class(es) to include based on the fact value. Do not try and select a node declaration based on a fact instead. Or am I still missing part of your intent? Cheers, Felix -- 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.
Felix, I have made the changes base on your feedback and it works well. Thanks for your assistance...rjl On Dec 20, 10:00 am, Felix Frank <felix.fr...@alumni.tu-berlin.de> wrote:> On 12/20/2010 05:55 PM, rjl wrote: > > > I have take it out of the case statement to try to resolve the > > problem. Here is an example. I receive the same error from this... > > > $tmp = "deving0109.cdntools.nsatc.net" > > node "${tmp}" { include adm } > > > But this works just fine... > > node "deving0109.cdntools.nsatc.net" { include adm } > > Well, I''m stumped. Maybe variable substition is just not meant to work > for node declarations. > > I still don''t see what you need it for. Your earlier post is a very good > depiction of how to choose a node''s role based on a fact: Do it by > selecting the class(es) to include based on the fact value. Do not try > and select a node declaration based on a fact instead. > > Or am I still missing part of your intent? > > Cheers, > Felix-- 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.
On Dec 20, 11:00 am, Felix Frank <felix.fr...@alumni.tu-berlin.de> wrote:> On 12/20/2010 05:55 PM, rjl wrote: > Well, I''m stumped. Maybe variable substition is just not meant to work > for node declarations.I could easily believe that. It doesn''t make much sense to me to use variable substitution in that context.> I still don''t see what you need it for. Your earlier post is a very good > depiction of how to choose a node''s role based on a fact: Do it by > selecting the class(es) to include based on the fact value. Do not try > and select a node declaration based on a fact instead.Exactly. You hit it on the head earlier when you said "this node definition will apply to each and every client." You can express that in Puppet by just putting the code at top level, outside any node definition. If it were me, though, I''d do it slightly differently: node default { case $osp_type { adm: { include adm } ... } } That way you can easily sidestep the whole $osp_type selection business if you need to do. rjl didn''t say specifically how he solved his problem, but I''m guessing it was in one of those two ways. John -- 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.
On Mon, Dec 20, 2010 at 2:43 PM, jcbollinger <John.Bollinger@stjude.org>wrote:> > > On Dec 20, 11:00 am, Felix Frank <felix.fr...@alumni.tu-berlin.de> > wrote: > > On 12/20/2010 05:55 PM, rjl wrote: > > Well, I''m stumped. Maybe variable substition is just not meant to work > > for node declarations. > > I could easily believe that. It doesn''t make much sense to me to use > variable substitution in that context. > > > I still don''t see what you need it for. Your earlier post is a very good > > depiction of how to choose a node''s role based on a fact: Do it by > > selecting the class(es) to include based on the fact value. Do not try > > and select a node declaration based on a fact instead. > > Exactly. You hit it on the head earlier when you said "this node > definition will apply to each and every client." You can express that > in Puppet by just putting the code at top level, outside any node > definition. > > If it were me, though, I''d do it slightly differently: > > node default { > case $osp_type { > adm: { include adm } > ... > } > } > > That way you can easily sidestep the whole $osp_type selection > business if you need to do. > > rjl didn''t say specifically how he solved his problem, but I''m > guessing it was in one of those two ways. > >I actually like to even abstract this even more away from the node itself. node default { include base } and then the "base" class does all logic around class/module inclusion. This means your environments are entirely self-contained, and you can pretty much ignore site.pp. You can do the same thing with your external node classifier as well. Always include "base" and set parameters there, then consult those values in your base module. -- 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.