I''m somewhat new to Puppet. I''m trying to establish some Virtual Resources so I can realize them based on a TAG. The error I continue to get is: Feb 16 18:02:38 test-fms puppet-agent[8590]: Could not retrieve catalog from remote server: Error 400 on SERVER: Syntax error at ''201001''; expected ''}'' at /etc/puppet/modules/dce/manifests/mounts.pp: 4 on node test-fms.domain.com The structure is, I believe, fairly simple. I''m using another module as a template (ghoneycutt::generic). There is a define of "nfsmount" under the init.pp: [ file name: init.pp ] class dce { define nfsmount(options} { } } a separate file, mounts.pp has this and is included as "include dce::mounts": [ file name: mounts.pp ] class dce::mounts { # 2010 @Dce::Nfsmount { "201001": device => "10.101.0.133", exportPath => "/dce/prod/201001", name => "/home/201001", tag => "2010", } } # class dce::mounts There is no missing bracket. I''ve looked at it a 100 times and I''m convinced of this. in the final script, called mounttest.pp (also under the "dce" module) I''m doing this: [ file name: mounttest.pp ] class dce::mounttest inherits dce { include dce::mounts Dce::Nfsmount <| tag == "2010" |> } Whether I "inherit" this or not does not change the outcome of the error. I would think that because it''s under the same module of dce that I would not need to include or inherit it. The dce::mounts file is just a list of Virtual Resources, that''s it. I simply can''t understand what I''m doing wrong. It''s probably so simple that I''m overlooking it. If anyone can lend a hand, I''d appreciate it. 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.
Felix Frank
2011-Feb-17 09:04 UTC
Re: [Puppet Users] Virtual Resources realization problems
Hi, On 02/17/2011 12:12 AM, Forrie wrote:> I''m somewhat new to Puppet. I''m trying to establish some Virtual > Resources so I can realize them based on a TAG. > > The error I continue to get is: > > Feb 16 18:02:38 test-fms puppet-agent[8590]: Could not retrieve > catalog from remote server: Error 400 on SERVER: Syntax error at > ''201001''; expected ''}'' at /etc/puppet/modules/dce/manifests/mounts.pp: > 4 on node test-fms.domain.com > > The structure is, I believe, fairly simple. I''m using another module > as a template (ghoneycutt::generic). > > There is a define of "nfsmount" under the init.pp: > > [ file name: init.pp ] > > class dce { > define nfsmount(options} { > } > } > > a separate file, mounts.pp has this and is included as "include > dce::mounts": > > [ file name: mounts.pp ] > > class dce::mounts { > > # 2010 > @Dce::Nfsmount { "201001":why is this capitalized? I disbelieve it should be.> device => "10.101.0.133", > exportPath => "/dce/prod/201001", > name => "/home/201001", > tag => "2010", > } > > } # class dce::mounts > > > There is no missing bracket. I''ve looked at it a 100 times and I''m > convinced of this. > > in the final script, called mounttest.pp (also under the "dce" module) > I''m doing this: > > [ file name: mounttest.pp ] > > class dce::mounttest inherits dce { > include dce::mounts > > Dce::Nfsmount <| tag == "2010" |> > > } > > Whether I "inherit" this or not does not change the outcome of the > error. I would think that because it''s under the same module of dce > that I would not need to include or inherit it.Don''t go around randomly inheriting classes. If you need to override a resource, inherit a class (and do not much more that override resources). Otherwise, don''t inherit (include instead). HTH, Felix> The dce::mounts file is just a list of Virtual Resources, that''s it. > > I simply can''t understand what I''m doing wrong. It''s probably so > simple that I''m overlooking it. > > If anyone can lend a hand, I''d appreciate it. > > > 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.
jcbollinger
2011-Feb-17 16:14 UTC
[Puppet Users] Re: Virtual Resources realization problems
Heed Felix''s advice. In particular, do not captialize class, definition, or resource type names when you *declare* a resource, including a virtual one. Do capitalize where you *realize* a virtual resource. Also, On Feb 16, 5:12 pm, Forrie <for...@gmail.com> wrote:> class dce { > define nfsmount(options} { > }If that''s a literal cut&paste from your manifest, then you will probably want to correct its syntax error, too. 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.
Thank you! That worked. I was actually following an incorrect example whereby the definition itself was capitalized. What really irks me here is that the error message I was getting was irrelevant -- at least, in my opinion it needed to be more specific with syntactical errors. There must be some clever tool out there that will parse puppet scripts for format and syntax. Something like that should be available within Puppet itself. It would have saved me a lot of trouble. In any case, a learning experience. I have another related question. What happens when a virtual resource such as an NFS mount is not longer needed -- how do you prune that from the systems that had it "realized"? Can you "unrealize" them? As for the define above for the initial "class dce {" that was typed out in pseudo code for brevity :-) Thanks again, I really appreciate it. -- 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.
Thank you! That worked. I was actually following an incorrect example whereby the definition itself was capitalized. What really irks me here is that the error message I was getting was irrelevant -- at least, in my opinion it needed to be more specific with syntactical errors. There must be some clever tool out there that will parse puppet scripts for format and syntax. Something like that should be available within Puppet itself. It would have saved me a lot of trouble. In any case, a learning experience. I have another related question. What happens when a virtual resource such as an NFS mount is not longer needed -- how do you prune that from the systems that had it "realized"? Can you "unrealize" them? As for the define above for the initial "class dce {" that was typed out in pseudo code for brevity :-) Thanks again, I really appreciate it. -- 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.
jcbollinger
2011-Feb-17 22:51 UTC
[Puppet Users] Re: Virtual Resources realization problems
On Feb 17, 2:25 pm, Forrie <for...@gmail.com> wrote:> I have another related question. What happens when a virtual resource > such as an NFS mount is not longer needed -- how do you prune that > from the systems that had it "realized"? Can you "unrealize" them?First, let''s get the conceptual framework right. Realizing a virtual resource for a given node tells Puppet that you want to manage that resource for that node. Whether it implies the resource will then be present depends on the resource''s declared properties. You can always change your manifest so that those resources are no longer realized on those nodes, but that won''t do what I think you''re looking for. It is important to understand that by default, omitting a resource from a node''s catalog simply leaves it unmanaged, which is not at all the same thing removing it from the node. An unmanaged resource might or might not be present, and if present its properties might have any values. From a Puppet perspective, omitting a resource from a node''s catalog means "I don''t care." Most Puppet resource types support particular parameter values that indicate that the resource should be absent from the node. Typically, including for the Mount resource type, that''s spelled "ensure => absent". Thus, to get rid of a mount on certain nodes, simply arrange for the ensure parameter of its corresponding Mount resource to take the value "absent". Puppet has several flavors of conditional statements that can help achieve that. Advanced Puppeteers might sometimes use class inheritance to achieve the result by overriding resource properties. If the resource is virtual, then you will have to realize it for that to have any effect. If, however, you are looking to control on every node whether a particular resource is present (and if so, its properties), then you don''t want a virtual resource at all. Instead, you want a concrete resource whose "ensure" property you twiddle appropriately. It is also possible to instruct Puppet to remove all unmanaged resources of given types (see the Resources resource type), but proceed with extreme caution if you take that approach. As a special (but common) case, you can purge unmanaged files and subdirectories of a given directory via the File resource type''s "purge" parameter. HTH, 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.