Stefan Baryakov
2011-Mar-10 20:42 UTC
[Puppet Users] question about auto requiring resources
Hi out there, Is there a good way to avoid auto-requiring of resources that are in modules, which are not included for a given node? Here is an example - there is a definition of a user, lets say a service service account, which is present on all nodes for given environment and some property of that user should only be set on some of the nodes. On the rest of the nodes that user should be unmanaged. In that case I would create a separate module with single class that manages this user and include this module only in the definitions of some of the nodes. The problem is that if you mention that user in some resource, lets say file{owner}, the class managing that user gets included form the auto-require even though it is not included by the external node classifier. Thanks Stefan -- 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 Mar 10, 2011, at 12:42 PM, Stefan Baryakov wrote:> The problem is that if you mention that user in some resource, lets > say file{owner}, the class managing that user gets included form the > auto-require even though it is not included by the external node > classifier.Auto-require won''t include a resource. It mostly works like this: autorequre(myresource) if myresource exists require(myresource) end if end autorequire -- 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.
Stefan Baryakov
2011-Mar-10 21:09 UTC
[Puppet Users] Re: question about auto requiring resources
Thanks for the response. What is the scope of "if myresource exists" part? From what I can tell it looks also in modules which are not included for given node. In my example Modules: class myuser {user {"myuser": homedir => /someplace } } class myfile { file {"myfile": owner => "myuser" }} node mynode { include myfile } In that case the homedir of myuser on mynode gets changed. Thanks Stefan On Mar 10, 9:47 pm, Patrick <kc7...@gmail.com> wrote:> On Mar 10, 2011, at 12:42 PM, Stefan Baryakov wrote: > > > The problem is that if you mention that user in some resource, lets > > say file{owner}, the class managing that user gets included form the > > auto-require even though it is not included by the external node > > classifier. > > Auto-require won''t include a resource. It mostly works like this: > > autorequre(myresource) > if myresource exists > require(myresource) > end if > end autorequire-- 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.
Patrick
2011-Mar-10 21:13 UTC
Re: [Puppet Users] Re: question about auto requiring resources
I''m almost sure this isn''t true could you put just that into a "test.pp" file and run that in master-less mode to check? In 0.25.x this would be "puppet --verbose --debug test.pp" In 2.6.x I think this would be "puppet apply --verbose --debug test.pp" Note: this is run on the client. On Mar 10, 2011, at 1:09 PM, Stefan Baryakov wrote:> Thanks for the response. > What is the scope of "if myresource exists" part? From what I can tell > it looks also in modules which are not included for given node. > > In my example > > Modules: > class myuser {user {"myuser": homedir => /someplace } } > class myfile { file {"myfile": owner => "myuser" }} > > node mynode { include myfile } > > In that case the homedir of myuser on mynode gets changed. > > Thanks > Stefan > > > > > On Mar 10, 9:47 pm, Patrick <kc7...@gmail.com> wrote: >> On Mar 10, 2011, at 12:42 PM, Stefan Baryakov wrote: >> >>> The problem is that if you mention that user in some resource, lets >>> say file{owner}, the class managing that user gets included form the >>> auto-require even though it is not included by the external node >>> classifier. >> >> Auto-require won''t include a resource. It mostly works like this: >> >> autorequre(myresource) >> if myresource exists >> require(myresource) >> end if >> end autorequire > > -- > 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.
Stefan Baryakov
2011-Mar-10 21:25 UTC
[Puppet Users] Re: question about auto requiring resources
yep. I''ll send you the result tomorrow. Note that the real setup is with 2.6.4 with external node classifier and myfile and myuser are in separate modules Regards, Stefan On Mar 10, 10:13 pm, Patrick <kc7...@gmail.com> wrote:> I''m almost sure this isn''t true could you put just that into a "test.pp" file and run that in master-less mode to check? > > In 0.25.x this would be "puppet --verbose --debug test.pp" > In 2.6.x I think this would be "puppet apply --verbose --debug test.pp" > > Note: this is run on the client. > > On Mar 10, 2011, at 1:09 PM, Stefan Baryakov wrote: > > > Thanks for the response. > > What is the scope of "if myresource exists" part? From what I can tell > > it looks also in modules which are not included for given node. > > > In my example > > > Modules: > > class myuser {user {"myuser": homedir => /someplace } } > > class myfile { file {"myfile": owner => "myuser" }} > > > node mynode { include myfile } > > > In that case the homedir of myuser on mynode gets changed. > > > Thanks > > Stefan > > > On Mar 10, 9:47 pm, Patrick <kc7...@gmail.com> wrote: > >> On Mar 10, 2011, at 12:42 PM, Stefan Baryakov wrote: > > >>> The problem is that if you mention that user in some resource, lets > >>> say file{owner}, the class managing that user gets included form the > >>> auto-require even though it is not included by the external node > >>> classifier. > > >> Auto-require won''t include a resource. It mostly works like this: > > >> autorequre(myresource) > >> if myresource exists > >> require(myresource) > >> end if > >> end autorequire > > > -- > > 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 athttp://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.
Patrick
2011-Mar-11 00:01 UTC
Re: [Puppet Users] Re: question about auto requiring resources
Actually, I was hoping you''d run it standalone so that the the other stuff wouldn''t interfere. On Mar 10, 2011, at 1:25 PM, Stefan Baryakov wrote:> yep. I''ll send you the result tomorrow. Note that the real setup is > with 2.6.4 with external node classifier and myfile and myuser are in > separate modules > > Regards, > Stefan > > On Mar 10, 10:13 pm, Patrick <kc7...@gmail.com> wrote: >> I''m almost sure this isn''t true could you put just that into a "test.pp" file and run that in master-less mode to check? >> >> In 0.25.x this would be "puppet --verbose --debug test.pp" >> In 2.6.x I think this would be "puppet apply --verbose --debug test.pp" >> >> Note: this is run on the client. >> >> On Mar 10, 2011, at 1:09 PM, Stefan Baryakov wrote: >> >>> Thanks for the response. >>> What is the scope of "if myresource exists" part? From what I can tell >>> it looks also in modules which are not included for given node. >> >>> In my example >> >>> Modules: >>> class myuser {user {"myuser": homedir => /someplace } } >>> class myfile { file {"myfile": owner => "myuser" }} >> >>> node mynode { include myfile } >> >>> In that case the homedir of myuser on mynode gets changed. >> >>> Thanks >>> Stefan >> >>> On Mar 10, 9:47 pm, Patrick <kc7...@gmail.com> wrote: >>>> On Mar 10, 2011, at 12:42 PM, Stefan Baryakov wrote: >> >>>>> The problem is that if you mention that user in some resource, lets >>>>> say file{owner}, the class managing that user gets included form the >>>>> auto-require even though it is not included by the external node >>>>> classifier. >> >>>> Auto-require won''t include a resource. It mostly works like this: >> >>>> autorequre(myresource) >>>> if myresource exists >>>> require(myresource) >>>> end if >>>> end autorequire >> >>> -- >>> 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 athttp://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. >-- 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.
Nick Fagerlund
2011-Mar-11 18:55 UTC
[Puppet Users] Re: question about auto requiring resources
Hi, Stefan. I can''t reproduce this on my 2.6.4 machines. Here''s what I''ve got: # moduledir/autoreqproblems/manifests/init.pp class autoreqproblems {} # moduledir/autoreqproblems/manifests/myfile.pp class autoreqproblems::myfile { file {"/tmp/myfile": ensure => file, owner => "davexx", } } # moduledir/autoreqproblems/manifests/myuser.pp class autoreqproblems::myuser { user {"davexx": home => ''/home/someplace'', ensure => present, managehome => true, } } # site.pp node ''barn2.magpie.lan'' { include autoreqproblems::myfile } [root@barn2]# puppet agent --test info: Retrieving plugin info: Loading facts in testfact info: Loading facts in testfact info: Caching catalog for barn2.magpie.lan info: Applying configuration version ''1299869350'' err: /Stage[main]/Autoreqproblems::Myfile/File[/tmp/myfile]/ensure: change from absent to file failed: Could not set ''file on ensure: Could not find user davexx at /etc/puppetlabs/puppet/modules/ autoreqproblems/manifests/myfile.pp:5 [root@barn2]# ls -lah /tmp total 40K drwxrwxrwt 4 root root 4.0K Mar 11 10:49 . drwxr-xr-x 25 root root 4.0K Dec 16 16:19 .. drwxrwxrwt 2 root root 4.0K Dec 16 16:19 .font-unix drwxrwxrwt 2 root root 4.0K Dec 16 16:19 .ICE-unix -rw------- 1 root root 0 Jan 3 14:01 mutt-barn2-6984-0 -rw-r--r-- 1 root root 0 Mar 11 10:49 myfile [root@barn2]# puppet resource user davexx user { ''davexx'': ensure => ''absent'' } Am I missing something? How can I reproduce your issue? On Mar 10, 1:09 pm, Stefan Baryakov <stefan.barya...@gmail.com> wrote:> Thanks for the response. > What is the scope of "if myresource exists" part? From what I can tell > it looks also in modules which are not included for given node. > > In my example > > Modules: > class myuser {user {"myuser": homedir => /someplace } } > class myfile { file {"myfile": owner => "myuser" }} > > node mynode { include myfile } > > In that case the homedir of myuser on mynode gets changed. > > Thanks > Stefan > > On Mar 10, 9:47 pm, Patrick <kc7...@gmail.com> wrote: > > > > > > > > > On Mar 10, 2011, at 12:42 PM, Stefan Baryakov wrote: > > > > The problem is that if you mention that user in some resource, lets > > > say file{owner}, the class managing that user gets included form the > > > auto-require even though it is not included by the external node > > > classifier. > > > Auto-require won''t include a resource. It mostly works like this: > > > autorequre(myresource) > > if myresource exists > > require(myresource) > > end if > > end autorequire-- 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.
Stefan Baryakov
2011-Mar-12 18:18 UTC
[Puppet Users] Re: question about auto requiring resources
Unfortunately I am not able to reproduce it as well. I must be going blind or something. The problem was actually with root password getting applied to all nodes even-though the module was included in some of the nodes only. The --debug log was saying autorequiring user root, while it wasn''t supposed to. I worked around that by adding "if defined" for the password variable. Sorry for the trouble. If I see that again I''ll collect all of the debugging Regards, Stefan On Mar 11, 7:55 pm, Nick Fagerlund <nick.fagerl...@puppetlabs.com> wrote:> Hi, Stefan. I can''t reproduce this on my 2.6.4 machines. Here''s what > I''ve got: > > # moduledir/autoreqproblems/manifests/init.pp > class autoreqproblems {} > > # moduledir/autoreqproblems/manifests/myfile.pp > class autoreqproblems::myfile { > file {"/tmp/myfile": > ensure => file, > owner => "davexx", > } > > } > > # moduledir/autoreqproblems/manifests/myuser.pp > class autoreqproblems::myuser { > user {"davexx": > home => ''/home/someplace'', > ensure => present, > managehome => true, > } > > } > > # site.pp > node ''barn2.magpie.lan'' { > include autoreqproblems::myfile > > } > > [root@barn2]# puppet agent --test > info: Retrieving plugin > info: Loading facts in testfact > info: Loading facts in testfact > info: Caching catalog for barn2.magpie.lan > info: Applying configuration version ''1299869350'' > err: /Stage[main]/Autoreqproblems::Myfile/File[/tmp/myfile]/ensure: > change from absent to file failed: Could not set ''file on ensure: > Could not find user davexx at /etc/puppetlabs/puppet/modules/ > autoreqproblems/manifests/myfile.pp:5 > > [root@barn2]# ls -lah /tmp > total 40K > drwxrwxrwt 4 root root 4.0K Mar 11 10:49 . > drwxr-xr-x 25 root root 4.0K Dec 16 16:19 .. > drwxrwxrwt 2 root root 4.0K Dec 16 16:19 .font-unix > drwxrwxrwt 2 root root 4.0K Dec 16 16:19 .ICE-unix > -rw------- 1 root root 0 Jan 3 14:01 mutt-barn2-6984-0 > -rw-r--r-- 1 root root 0 Mar 11 10:49 myfile > [root@barn2]# puppet resource user davexx > user { ''davexx'': > ensure => ''absent'' > > } > > Am I missing something? How can I reproduce your issue? > > On Mar 10, 1:09 pm, Stefan Baryakov <stefan.barya...@gmail.com> wrote: > > > Thanks for the response. > > What is the scope of "if myresource exists" part? From what I can tell > > it looks also in modules which are not included for given node. > > > In my example > > > Modules: > > class myuser {user {"myuser": homedir => /someplace } } > > class myfile { file {"myfile": owner => "myuser" }} > > > node mynode { include myfile } > > > In that case the homedir of myuser on mynode gets changed. > > > Thanks > > Stefan > > > On Mar 10, 9:47 pm, Patrick <kc7...@gmail.com> wrote: > > > > On Mar 10, 2011, at 12:42 PM, Stefan Baryakov wrote: > > > > > The problem is that if you mention that user in some resource, lets > > > > say file{owner}, the class managing that user gets included form the > > > > auto-require even though it is not included by the external node > > > > classifier. > > > > Auto-require won''t include a resource. It mostly works like this: > > > > autorequre(myresource) > > > if myresource exists > > > require(myresource) > > > end if > > > end autorequire-- 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.