Asif Iqbal
2009-Aug-11 19:17 UTC
[Puppet Users] resources from specific class only to apply to a node
Hi do I apply only one class to a node? In my `site.pp'' file I am saying puppet@sys-ubuntu:/etc/puppet$ cat manifests/site.pp #site.pp import "classes/*.pp" node default { include nmc-delete } But the node is also getting resources from other classes like `nmc'' notice: //Nmc::Myuser[tkimpto]/User[tkimpto]/ensure: created Here is a list of classes puppet@sys-ubuntu:/etc/puppet$ ls -1 manifests/classes/*.pp manifests/classes/newungrp.pp manifests/classes/newuthngrp.pp manifests/classes/nmc2.pp manifests/classes/nmc-delete.pp manifests/classes/nmc.pp manifests/classes/sudo.pp How do I force a node to get resources only from one specific class and do not look into others? -- Asif Iqbal PGP Key: 0xE62693C5 KeyServer: pgp.mit.edu A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Nigel Kersten
2009-Aug-11 19:22 UTC
[Puppet Users] Re: resources from specific class only to apply to a node
On Tue, Aug 11, 2009 at 12:17 PM, Asif Iqbal <vadud3@gmail.com> wrote:> > Hi do I apply only one class to a node? > > In my `site.pp'' file I am saying > > puppet@sys-ubuntu:/etc/puppet$ cat manifests/site.pp > #site.pp > import "classes/*.pp" > > node default { include nmc-delete } > > But the node is also getting resources from other classes like `nmc'' > > notice: //Nmc::Myuser[tkimpto]/User[tkimpto]/ensure: created > > Here is a list of classes > puppet@sys-ubuntu:/etc/puppet$ ls -1 manifests/classes/*.pp > manifests/classes/newungrp.pp > manifests/classes/newuthngrp.pp > manifests/classes/nmc2.pp > manifests/classes/nmc-delete.pp > manifests/classes/nmc.pp > manifests/classes/sudo.pp > > How do I force a node to get resources only from one specific class > and do not look into others?http://reductivelabs.com/trac/puppet/wiki/UsingTags particularly "Classes automatically tag everything in them with the class name, so this isn''t usually needed. This works the same way in nodes." -- Nigel Kersten nigelk@google.com System Administrator Google, Inc. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Asif Iqbal
2009-Aug-11 20:13 UTC
[Puppet Users] Re: resources from specific class only to apply to a node
On Tue, Aug 11, 2009 at 3:22 PM, Nigel Kersten<nigelk@google.com> wrote:> > > On Tue, Aug 11, 2009 at 12:17 PM, Asif Iqbal <vadud3@gmail.com> wrote: >> >> Hi do I apply only one class to a node? >> >> In my `site.pp'' file I am saying >> >> puppet@sys-ubuntu:/etc/puppet$ cat manifests/site.pp >> #site.pp >> import "classes/*.pp" >> >> node default { include nmc-delete } >> >> But the node is also getting resources from other classes like `nmc'' >> >> notice: //Nmc::Myuser[tkimpto]/User[tkimpto]/ensure: created >> >> Here is a list of classes >> puppet@sys-ubuntu:/etc/puppet$ ls -1 manifests/classes/*.pp >> manifests/classes/newungrp.pp >> manifests/classes/newuthngrp.pp >> manifests/classes/nmc2.pp >> manifests/classes/nmc-delete.pp >> manifests/classes/nmc.pp >> manifests/classes/sudo.pp >> >> How do I force a node to get resources only from one specific class >> and do not look into others? > > http://reductivelabs.com/trac/puppet/wiki/UsingTags > > particularly "Classes automatically tag everything in them with the class > name, so this isn''t usually needed. This works the same way in nodes."ok so using --tage classname works just fine. thanks a lot. learned something cool however, if I run the puppetd as a daemon, then I like to control this from the puppetmasterd. Is is possible to config a resource where a node will only get a specific class and nothing else?> > > > > -- > Nigel Kersten > nigelk@google.com > System Administrator > Google, Inc. > > > >-- Asif Iqbal PGP Key: 0xE62693C5 KeyServer: pgp.mit.edu A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? --~--~---------~--~----~------------~-------~--~----~ 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
2009-Aug-12 13:03 UTC
[Puppet Users] Re: resources from specific class only to apply to a node
On Aug 11, 3:13 pm, Asif Iqbal <vad...@gmail.com> wrote: [...]> ok so using --tage classname works just fine. thanks a lot. learned > something cool > > however, if I run the puppetd as a daemon, then I like to control this > from the puppetmasterd. > > Is is possible to config a resource where a node will only get a > specific class and nothing else?Puppetmasterd matches exactly one node spec to each client, using the default node spec if no others match. The classes specified by the chosen node spec (and only those) are applied to that client. That''s how it should be, and that''s how it works for me in version 0.24.8. I can think of several possible explanations for the behavior you see: 1) Your "nmc-delete" class includes other classes, which are therefore also applied to any node that gets nmc-delete. 2) You have another node spec somewhere (nodes.pp ?) that matches your client more closely than the default node spec, and you are getting the extra classes from there. 3) You are not talking to the puppetmaster you think you are talking to (e.g., test vs. production). There are surely other possibilities, but those seem the most likely to me. 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 -~----------~----~----~----~------~----~------~--~---
Asif Iqbal
2009-Aug-12 14:53 UTC
[Puppet Users] Re: resources from specific class only to apply to a node
On Wed, Aug 12, 2009 at 9:03 AM, jcbollinger<John.Bollinger@stjude.org> wrote:> > > > On Aug 11, 3:13 pm, Asif Iqbal <vad...@gmail.com> wrote: > [...] >> ok so using --tage classname works just fine. thanks a lot. learned >> something cool >> >> however, if I run the puppetd as a daemon, then I like to control this >> from the puppetmasterd. >> >> Is is possible to config a resource where a node will only get a >> specific class and nothing else? > > Puppetmasterd matches exactly one node spec to each client, using the > default node spec if no others match. The classes specified by the > chosen node spec (and only those) are applied to that client. That''s > how it should be, and that''s how it works for me in version 0.24.8.I am using 0.24.5 in ubuntu. That seems to be latest pkg. May be I should compile it from source?> > I can think of several possible explanations for the behavior you see: > > 1) Your "nmc-delete" class includes other classes, which are therefore > also applied to any node that gets nmc-delete.puppet@sys-ubuntu:/etc/puppet/manifests$ cat classes/nmc-delete.pp class nmc-delete { define mygroup ($gid){ group { "$title": gid => "$gid", ensure => present, } } define deluser { exec { "/usr/sbin/userdel $name": } exec { "/usr/bin/rm -rf /export/home/$name": } } } nmc-delete::deluser { "seagate": } nmc-delete::deluser { "abradley": } nmc-delete::deluser { "bobrien": } puppet@sys-ubuntu:/etc/puppet/manifests$ cat classes/nmc.pp class nmc { define mygroup ($gid){ group { "$title": gid => "$gid", ensure => present, } } define myuser ($uid,$gid=1,$comment,$shell,$home,$password) { user { $name: ensure => present, uid => "$uid", gid => "$gid", comment => "$comment", shell => "/bin/bash", password => "$password", managehome => true, home => "/export/home/$name", } } } nmc::mygroup { "group1": gid => "70006" } nmc::mygroup { "group2": gid => "15" } nmc::mygroup { "dba": gid => "101" } nmc::myuser { "seagate": uid => "120", gid => "10", password => ".i0gouaHfLC2", comment => "", home => "/home/seagate", shell => "/bin/sh", } nmc::myuser { "abradley": uid => "1025", gid => "10", password => "blzEZiPmJx1Y", comment => "Alex Bradley", home => "/home/abradley", shell => "/bin/ksh", } nmc::myuser { "bobrien": uid => "1009", gid => "10", password => "prg2i/aA5cPk", comment => "Bill O''Brien", home => "/home/bobrien", shell => "/usr/local/bin/tcsh", } nmc::myuser { "bwhelton": uid => "1045", gid => "10", password => "XSnR6poHGUk", comment => "Bob Whelton", home => "/home/bwhelton", shell => "/usr/local/bin/bash", }> > 2) You have another node spec somewhere (nodes.pp ?) that matches your > client more closely than the default node spec, and you are getting > the extra classes from there.I don''t have any nodes.pp file puppet@sys-ubuntu:/etc/puppet/manifests$ ls -lR .: total 168 drwxr-xr-x 2 puppet puppet 4096 2009-08-11 16:06 classes drwxr-xr-x 2 puppet puppet 4096 2009-06-29 13:01 definitions drwxr-xr-x 3 puppet puppet 4096 2009-06-29 15:14 files -rw-r--r-- 1 puppet puppet 459 2009-06-29 15:14 fileserver.conf drwxr-xr-x 2 puppet puppet 4096 2009-06-29 13:01 groups drwxr-xr-x 2 puppet puppet 4096 2009-06-29 13:01 os -rw-r--r-- 1 puppet puppet 83326 2009-08-09 15:32 out -rw-r--r-- 1 puppet puppet 144 2009-08-11 14:49 site.pp drwxr-xr-x 2 puppet puppet 4096 2009-06-29 13:01 templates -rw-r--r-- 1 puppet puppet 0 2009-07-01 12:10 templates.pp drwxr-xr-x 2 puppet puppet 4096 2009-06-29 13:01 users ./classes: total 32 -rw-r--r-- 1 puppet puppet 484 2009-08-11 13:41 newungrp.pp -rw-r--r-- 1 puppet puppet 362 2009-08-11 13:45 newuthngrp.pp -rw-r--r-- 1 puppet puppet 655 2009-08-11 14:14 nmc2.pp -rw-r--r-- 1 puppet puppet 1532 2009-08-11 16:06 nmc-delete.pp -rw-r--r-- 1 puppet puppet 6932 2009-08-11 16:06 nmc.pp -rw-r--r-- 1 puppet puppet 121 2009-03-19 16:19 sudo.pp -rw-r--r-- 1 puppet puppet 277 2009-08-07 12:19 user.pp.test ./definitions: total 0 ./files: total 0 ./groups: total 0 ./os: total 0 ./templates: total 0 ./users: total 0> > 3) You are not talking to the puppetmaster you think you are talking > to (e.g., test vs. production).I have only puppetmaster and that is not production yet.> > There are surely other possibilities, but those seem the most likely > to me. > > > John > > >-- Asif Iqbal PGP Key: 0xE62693C5 KeyServer: pgp.mit.edu A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? --~--~---------~--~----~------------~-------~--~----~ 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
2009-Aug-13 14:48 UTC
[Puppet Users] Re: resources from specific class only to apply to a node
On Aug 12, 9:53 am, Asif Iqbal <vad...@gmail.com> wrote:> On Wed, Aug 12, 2009 at 9:03 AM, jcbollinger<John.Bollin...@stjude.org> wrote: > > > On Aug 11, 3:13 pm, Asif Iqbal <vad...@gmail.com> wrote:[...]> >> Is is possible to config a resource where a node will only get a > >> specific class and nothing else? > > > Puppetmasterd matches exactly one node spec to each client, using the > > default node spec if no others match. The classes specified by the > > chosen node spec (and only those) are applied to that client. That''s > > how it should be, and that''s how it works for me in version 0.24.8.> > I can think of several possible explanations for the behavior you see: > > > 1) Your "nmc-delete" class includes other classes, which are therefore > > also applied to any node that gets nmc-delete. > > puppet@sys-ubuntu:/etc/puppet/manifests$ cat classes/nmc-delete.pp > class nmc-delete { > define mygroup ($gid){ > group { "$title": > gid => "$gid", > ensure => present, > } > } > define deluser { > exec { "/usr/sbin/userdel $name": } > exec { "/usr/bin/rm -rf /export/home/$name": } > } > > }AHA! These resources do not belong to any class; they are top-level:> nmc-delete::deluser { "seagate": } > nmc-delete::deluser { "abradley": } > nmc-delete::deluser { "bobrien": } > > puppet@sys-ubuntu:/etc/puppet/manifests$ cat classes/nmc.pp > class nmc { > define mygroup ($gid){[...]> } > define myuser ($uid,$gid=1,$comment,$shell,$home,$password) {[...]> } > > }More top-level resources:> nmc::mygroup { "group1": gid => "70006" } > nmc::mygroup { "group2": gid => "15" } > nmc::mygroup { "dba": gid => "101" } > > nmc::myuser { "seagate": > uid => "120", > gid => "10", > password => ".i0gouaHfLC2", > comment => "", > home => "/home/seagate", > shell => "/bin/sh", > > }[...] As I hinted above, I think I see the problem. If I''m reading your manifests correctly, your resources are not in classes at all. They are being applied [only] because you are importing them directly into site.pp. I think you need to structure your code something like this: class nmc-delete { define mygroup ($gid){ group { "$title": gid => "$gid", ensure => present, } } define deluser { exec { "/usr/sbin/userdel $name": } exec { "/usr/bin/rm -rf /export/home/$name": } } deluser { "seagate": } deluser { "abradley": } deluser { "bobrien": } } (And similarly for your other manifests.) 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 -~----------~----~----~----~------~----~------~--~---
Asif Iqbal
2009-Aug-13 19:44 UTC
[Puppet Users] Re: resources from specific class only to apply to a node
On Thu, Aug 13, 2009 at 10:48 AM, jcbollinger<John.Bollinger@stjude.org> wrote:> > > On Aug 12, 9:53 am, Asif Iqbal <vad...@gmail.com> wrote: >> On Wed, Aug 12, 2009 at 9:03 AM, jcbollinger<John.Bollin...@stjude.org> wrote: >> >> > On Aug 11, 3:13 pm, Asif Iqbal <vad...@gmail.com> wrote: > > [...] > >> >> Is is possible to config a resource where a node will only get a >> >> specific class and nothing else? >> >> > Puppetmasterd matches exactly one node spec to each client, using the >> > default node spec if no others match. The classes specified by the >> > chosen node spec (and only those) are applied to that client. That''s >> > how it should be, and that''s how it works for me in version 0.24.8. > >> > I can think of several possible explanations for the behavior you see: >> >> > 1) Your "nmc-delete" class includes other classes, which are therefore >> > also applied to any node that gets nmc-delete. >> >> puppet@sys-ubuntu:/etc/puppet/manifests$ cat classes/nmc-delete.pp >> class nmc-delete { >> define mygroup ($gid){ >> group { "$title": >> gid => "$gid", >> ensure => present, >> } >> } >> define deluser { >> exec { "/usr/sbin/userdel $name": } >> exec { "/usr/bin/rm -rf /export/home/$name": } >> } >> >> } > > AHA! These resources do not belong to any class; they are top-level: > >> nmc-delete::deluser { "seagate": } >> nmc-delete::deluser { "abradley": } >> nmc-delete::deluser { "bobrien": } >> >> puppet@sys-ubuntu:/etc/puppet/manifests$ cat classes/nmc.pp >> class nmc { >> define mygroup ($gid){ > > [...] > >> } >> define myuser ($uid,$gid=1,$comment,$shell,$home,$password) { > > [...] > >> } >> >> } > > More top-level resources: > >> nmc::mygroup { "group1": gid => "70006" } >> nmc::mygroup { "group2": gid => "15" } >> nmc::mygroup { "dba": gid => "101" } >> >> nmc::myuser { "seagate": >> uid => "120", >> gid => "10", >> password => ".i0gouaHfLC2", >> comment => "", >> home => "/home/seagate", >> shell => "/bin/sh", >> >> } > > [...] > > As I hinted above, I think I see the problem. If I''m reading your > manifests correctly, your resources are not in classes at all. They > are being applied [only] because you are importing them directly into > site.pp. I think you need to structure your code something like this:that is exactly what I was doing wrong. it is working now as I expected it to work. Thanks a lot in helping to fix the manifests.> > class nmc-delete { > define mygroup ($gid){ > group { "$title": > gid => "$gid", > ensure => present, > } > } > define deluser { > exec { "/usr/sbin/userdel $name": } > exec { "/usr/bin/rm -rf /export/home/$name": } > } > > deluser { "seagate": } > deluser { "abradley": } > deluser { "bobrien": } > > } > > > (And similarly for your other manifests.) > > > John > > >-- Asif Iqbal PGP Key: 0xE62693C5 KeyServer: pgp.mit.edu A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---