Edward Bailey
2008-Jun-27 03:54 UTC
[Puppet Users] testing for the existing of files or output
Please excuse what I am sure is a basic question but I am clearly not getting something How would I test for the existence of a file ie ####################### if "/etc/test" exists if file does exist then execute file type and restart service ####################### I know how to test for the existence of a file using the exec type - can I use the exec type and then ifonly to test for the existence of the file then embed a file type in the exec type that will execute if the file exists? I tried to get it to work but no luck. If this is possible, could someone share an example? Also I would like to use the output of something lspci -vv then grep for a string then execute a package type based on the output. Would it be a better to setup a custom fact instead of using an exec type to get this to work? Thanks in advance for help, I am feeling lost Ed --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Peter Meier
2008-Jun-27 06:58 UTC
[Puppet Users] Re: testing for the existing of files or output
Hi> Please excuse what I am sure is a basic question but I am clearly not > getting something > > How would I test for the existence of a file ie > > ####################### > if "/etc/test" exists > > if file does exist > > then execute file type > > and > > restart service > ####################### > > I know how to test for the existence of a file using the exec type - can I > use the exec type and then ifonly to test for the existence of the file then > embed a file type in the exec type that will execute if the file exists? I > tried to get it to work but no luck. > > If this is possible, could someone share an example?writing without testing: exec{''exec_file_type'': onlyif => ''test -e /etc/test'', command => ''/foobar/file_type'', notify => Service[''foobar''], } Service{''foobar'': ensure => running, enable => true, } If it wasn''t working, what was the exact problem? greets pete --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Edward Bailey
2008-Jun-27 11:57 UTC
[Puppet Users] Re: testing for the existing of files or output
> > > > writing without testing: > > exec{''exec_file_type'': > onlyif => ''test -e /etc/test'', > command => ''/foobar/file_type'', > notify => Service[''foobar''], > } > > Service{''foobar'': > ensure => running, > enable => true, > } > > If it wasn''t working, what was the exact problem? > > greets pete >How does "exec{''exec_file_type'': onlyif => ''test -e /etc/test'', command => ''/foobar/file_type'', notify => Service[''foobar'']," execute a file type and pull a standard file from the puppetmaster? That is what I can''t figure out. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Evan Hisey
2008-Jun-27 14:00 UTC
[Puppet Users] Re: testing for the existing of files or output
>> >> writing without testing: >> >> exec{''exec_file_type'': >> onlyif => ''test -e /etc/test'', >> command => ''/foobar/file_type'', >> notify => Service[''foobar''], >> } >> >> Service{''foobar'': >> ensure => running, >> enable => true, >> } >> >> If it wasn''t working, what was the exact problem? >> > How does > > "exec{''exec_file_type'': > onlyif => ''test -e /etc/test'', > command => ''/foobar/file_type'', > notify => Service[''foobar'']," > > execute a file type and pull a standard file from the puppetmaster? > > That is what I can''t figure out.In short it does not. You did not make it clear that you needed to pull a file down if one was already present. I think part of your problem is mental approach to using puppet. If you are still thinking files when using puppet, you often one of three things going, 1) an edge case 2) approach to problem is wrong, 3) a miss application of puppet. 2 and 3 are the most common, with 2 the winner of that honor. Case 3 is getting rarer but still happens. Can you expand a bit on what you are trying to do? Not at teh step by step level but a higher abstraction level. The only way to pull files form the puppet server is with the File type. The file type can do a lot things but without a higher level of knowledge aboutwhat you are attempting it will be hard to give you good help. Evan --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Peter Meier
2008-Jun-27 14:12 UTC
[Puppet Users] Re: testing for the existing of files or output
Hi> execute a file type and pull a standard file from the puppetmaster?ah execute a file type, as a puppet file type, no i understand what you mean. i was unsure already before, what you mean with file type and if I understood you correctly. well you cannot "execute file types" afaik. but you could wrap the file type in an if statement and the decision variable could be an own fact, which tests for the file. greets pete --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Edward Bailey
2008-Jun-28 19:00 UTC
[Puppet Users] Re: testing for the existing of files or output
We have a number of different servers with different raid cards and I want to get some control of management of the raid card management config files. I "think" I have to write a class for each particular class of raid card and then assign the class to the correct server in the node list. I would prefer to create one class that can test for the existence of the raid card management config file such as /etc/srcd.conf and then manage the file using a file type and then restart the service as needed. Does this give you a better idea of what I am looking for? I am going to work on my approach some more and see what I can come up with. Thansk Ed On Fri, Jun 27, 2008 at 10:00 AM, Evan Hisey <ehisey@gmail.com> wrote:> > >> > >> writing without testing: > >> > >> exec{''exec_file_type'': > >> onlyif => ''test -e /etc/test'', > >> command => ''/foobar/file_type'', > >> notify => Service[''foobar''], > >> } > >> > >> Service{''foobar'': > >> ensure => running, > >> enable => true, > >> } > >> > >> If it wasn''t working, what was the exact problem? > >> > > How does > > > > "exec{''exec_file_type'': > > onlyif => ''test -e /etc/test'', > > command => ''/foobar/file_type'', > > notify => Service[''foobar'']," > > > > execute a file type and pull a standard file from the puppetmaster? > > > > That is what I can''t figure out. > > In short it does not. You did not make it clear that you needed to > pull a file down if one was already present. I think part of your > problem is mental approach to using puppet. If you are still thinking > files when using puppet, you often one of three things going, 1) an > edge case 2) approach to problem is wrong, 3) a miss application of > puppet. 2 and 3 are the most common, with 2 the winner of that honor. > Case 3 is getting rarer but still happens. Can you expand a bit on > what you are trying to do? Not at teh step by step level but a higher > abstraction level. > > The only way to pull files form the puppet server is with the File > type. The file type can do a lot things but without a higher level of > knowledge aboutwhat you are attempting it will be hard to give you > good help. > > Evan > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Peter Meier
2008-Jun-28 19:05 UTC
[Puppet Users] Re: testing for the existing of files or output
Hi> We have a number of different servers with different raid cards and I want > to get some control of management of the raid card management config files. > I "think" I have to write a class for each particular class of raid card and > then assign the class to the correct server in the node list. I would prefer > to create one class that can test for the existence of the raid card > management config file such as /etc/srcd.conf and then manage the file using > a file type and then restart the service as needed. > > Does this give you a better idea of what I am looking for? I am going to > work on my approach some more and see what I can come up with.in my opionion a custom fact returning the raid card type and including based on this information the concrete class is the solution for your problem. greets pete --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Edward Bailey
2008-Jun-28 19:08 UTC
[Puppet Users] Re: testing for the existing of files or output
ok - i have made several other custom facts so that should be pretty easy - thanks for your help working out this issue. I really appreciate everyone''s time. Ed On Sat, Jun 28, 2008 at 3:05 PM, Peter Meier <peter.meier@immerda.ch> wrote:> > Hi > > > We have a number of different servers with different raid cards and I > want > > to get some control of management of the raid card management config > files. > > I "think" I have to write a class for each particular class of raid card > and > > then assign the class to the correct server in the node list. I would > prefer > > to create one class that can test for the existence of the raid card > > management config file such as /etc/srcd.conf and then manage the file > using > > a file type and then restart the service as needed. > > > > Does this give you a better idea of what I am looking for? I am going to > > work on my approach some more and see what I can come up with. > > in my opionion a custom fact returning the raid card type and including > based on this information the concrete class is the solution for your > problem. > > greets pete > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Peter Meier
2008-Jun-28 19:11 UTC
[Puppet Users] Re: testing for the existing of files or output
Hi> ok - i have made several other custom facts so that should be pretty easy - > thanks for your help working out this issue. I really appreciate everyone''s > time.no problem. welcome aboard and thanks for your help in other cases. greets pete --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---