A file that this command creates. If this parameter is provided, then the command will only be run if the specified file does not exist:: exec { \"tar xf /my/tar/file.tar\": cwd => \"/var/tmp\", creates => \"/var/tmp/myfile\", path => [\"/usr/bin\", \"/usr/sbin\"] } Is there a way to set the content of this file (/var/tmp/myfile) using some additional parameter in the above syntax? --- Thanks, Allan Marcus 505-667-5666
> Is there a way to set the content of this file (/var/tmp/myfile) > using some additional parameter in the above syntax?the file should be created by the command itself and should represent that what the command should setup is actually setup. Puppet won''t create this file, nor it will control the content of that file. cheers 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.
ahh, ok. We are planning on using the "creates" parameter as an "run this unless file is there" directive. Our scenario is that we need to run one time scripts on machines. We figure we can use a file type to create a local script to run, then use the exec to exec the script. At the end of the script we will "touch /var/puppet/receipts/somefile". Might look something like this. If there is a better way to push a one time script to nodes, please let me know. class run_one_time { file { "/var/puppet/script/myscript001.sh": content => "#!/bin/sh; do a bunch of stuff; touch /var/puppet/receipts/myscript001;" before => Exec[runOnce] } exec { runOnce: command => "/var/puppet/script/myscript.sh", creates => "/var/puppet/receipts/myscript001", path => ["/usr/bin", "/usr/sbin"] } } --- Thanks, Allan Marcus 505-667-5666 On Mar 4, 2010, at 8:43 AM, Peter Meier wrote:> >> Is there a way to set the content of this file (/var/tmp/myfile) using some additional parameter in the above syntax? > > the file should be created by the command itself and should represent that what the command should setup is actually setup. Puppet won''t create this file, nor it will control the content of that file. > > cheers 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. >
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi> We are planning on using the "creates" parameter as an "run this > unless file is there" directive. Our scenario is that we need to run > one time scripts on machines. We figure we can use a file type to > create a local script to run, then use the exec to exec the script. > At the end of the script we will "touch > /var/puppet/receipts/somefile". Might look something like this. If > there is a better way to push a one time script to nodes, please let > me know.seems to be a good idea. cheers pete -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkuP8A8ACgkQbwltcAfKi3+6ZQCeM0YsQgAwiTKJnDNBrlYNpd82 HegAn2iiPLRgX45B6noSWu+LXVqc9kll =nUxc -----END PGP SIGNATURE----- -- 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 4, 2010, at 7:29 AM, Allan Marcus wrote:> A file that this command creates. If this > parameter is provided, then the command will only be run > if the specified file does not exist:: > > exec { \"tar xf /my/tar/file.tar\": > cwd => \"/var/tmp\", > creates => \"/var/tmp/myfile\", > path => [\"/usr/bin\", \"/usr/sbin\"] > } > > > Is there a way to set the content of this file (/var/tmp/myfile) using some additional parameter in the above syntax?This isn''t the "right" way to do it, and you may have performance issues depending on the size of the file, but you can always combine grep with unless. If you want to re-extract the file if the file doesn''t contain "testString" this should work. exec { "tar xf /my/tar/file.tar": cwd => "/var/tmp", creates => "/var/tmp/myfile", path => ["/usr/bin", "/usr/sbin"], unless => "grep testString myfile", } -- 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.
If you don''t care about the contents of the file, just whether it''s there or not: unless => "/usr/bin/file MYFILE" or unless => "/usr/bin/stat MYFILE" or unless => "/bin/ls MYFILE" should all be pretty lightweight On Thu, Mar 4, 2010 at 12:06 PM, Patrick <kc7zzv@gmail.com> wrote:> > On Mar 4, 2010, at 7:29 AM, Allan Marcus wrote: > >> A file that this command creates. If this >> parameter is provided, then the command will only be run >> if the specified file does not exist:: >> >> exec { \"tar xf /my/tar/file.tar\": >> cwd => \"/var/tmp\", >> creates => \"/var/tmp/myfile\", >> path => [\"/usr/bin\", \"/usr/sbin\"] >> } >> >> >> Is there a way to set the content of this file (/var/tmp/myfile) using some additional parameter in the above syntax? > > This isn''t the "right" way to do it, and you may have performance issues depending on the size of the file, but you can always combine grep with unless. > > If you want to re-extract the file if the file doesn''t contain "testString" this should work. > > exec { "tar xf /my/tar/file.tar": > cwd => "/var/tmp", > creates => "/var/tmp/myfile", > path => ["/usr/bin", "/usr/sbin"], > unless => "grep testString myfile", > } > > > -- > 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.
Pete Emerson writes: > If you don''t care about the contents of the file, just whether it''s > there or not: > > unless => "/usr/bin/file MYFILE" > > or > > unless => "/usr/bin/stat MYFILE" > > or > > unless => "/bin/ls MYFILE" > > should all be pretty lightweight Actually, if all "unless" looks at is the return code of the command I would probably go with unless => "test -e MYFILE" If you use "test" you could also do more sophisticated things like require the presence of a real file with "-f" and combine other tests for permissions or ownership. > On Thu, Mar 4, 2010 at 12:06 PM, Patrick <kc7zzv@gmail.com> wrote: > > > > On Mar 4, 2010, at 7:29 AM, Allan Marcus wrote: > > > >> A file that this command creates. If this > >> parameter is provided, then the command will only be run > >> if the specified file does not exist:: > >> > >> exec { \"tar xf /my/tar/file.tar\": > >> cwd => \"/var/tmp\", > >> creates => \"/var/tmp/myfile\", > >> path => [\"/usr/bin\", \"/usr/sbin\"] > >> } > >> > >> > >> Is there a way to set the content of this file (/var/tmp/myfile) using some additional parameter in the above syntax? > > > > This isn''t the "right" way to do it, and you may have performance issues depending on the size of the file, but you can always combine grep with unless. > > > > If you want to re-extract the file if the file doesn''t contain "testString" this should work. > > > > exec { "tar xf /my/tar/file.tar": > > cwd => "/var/tmp", > > creates => "/var/tmp/myfile", > > path => ["/usr/bin", "/usr/sbin"], > > unless => "grep testString myfile", > > } > > > > > > -- > > 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. > -- 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.
The method you suggest is how we were first going to do a "one time script", but then we saw the "creates" parameter. What is the Creates parameter for then? Is it just redundant to [unless => "test -e MYFILE"] --- Thanks, Allan Marcus 505-667-5666 On Mar 4, 2010, at 2:36 PM, Steven VanDevender wrote:> Pete Emerson writes: >> If you don''t care about the contents of the file, just whether it''s >> there or not: >> >> unless => "/usr/bin/file MYFILE" >> >> or >> >> unless => "/usr/bin/stat MYFILE" >> >> or >> >> unless => "/bin/ls MYFILE" >> >> should all be pretty lightweight > > Actually, if all "unless" looks at is the return code of the command I > would probably go with > > unless => "test -e MYFILE" > > If you use "test" you could also do more sophisticated things like > require the presence of a real file with "-f" and combine other tests for > permissions or ownership. > >> On Thu, Mar 4, 2010 at 12:06 PM, Patrick <kc7zzv@gmail.com> wrote: >>> >>> On Mar 4, 2010, at 7:29 AM, Allan Marcus wrote: >>> >>>> A file that this command creates. If this >>>> parameter is provided, then the command will only be run >>>> if the specified file does not exist:: >>>> >>>> exec { \"tar xf /my/tar/file.tar\": >>>> cwd => \"/var/tmp\", >>>> creates => \"/var/tmp/myfile\", >>>> path => [\"/usr/bin\", \"/usr/sbin\"] >>>> } >>>> >>>> >>>> Is there a way to set the content of this file (/var/tmp/myfile) using some additional parameter in the above syntax? >>> >>> This isn''t the "right" way to do it, and you may have performance issues depending on the size of the file, but you can always combine grep with unless. >>> >>> If you want to re-extract the file if the file doesn''t contain "testString" this should work. >>> >>> exec { "tar xf /my/tar/file.tar": >>> cwd => "/var/tmp", >>> creates => "/var/tmp/myfile", >>> path => ["/usr/bin", "/usr/sbin"], >>> unless => "grep testString myfile", >>> } >>> >>> >>> -- >>> 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. >> > > -- > 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.
On Mar 5, 2010, at 8:46 AM, Allan Marcus wrote:> The method you suggest is how we were first going to do a "one time script", but then we saw the "creates" parameter. > > What is the Creates parameter for then? Is it just redundant to [unless => "test -e MYFILE"] > > --- >Mostly, it''s just a nicer syntax. Also, make sure that the command won''t hose you computer if run twice. It''s always possible that the puppet run will stop before the file is created.> > > > On Mar 4, 2010, at 2:36 PM, Steven VanDevender wrote: > >> Pete Emerson writes: >>> If you don''t care about the contents of the file, just whether it''s >>> there or not: >>> >>> unless => "/usr/bin/file MYFILE" >>> >>> or >>> >>> unless => "/usr/bin/stat MYFILE" >>> >>> or >>> >>> unless => "/bin/ls MYFILE" >>> >>> should all be pretty lightweight >> >> Actually, if all "unless" looks at is the return code of the command I >> would probably go with >> >> unless => "test -e MYFILE" >> >> If you use "test" you could also do more sophisticated things like >> require the presence of a real file with "-f" and combine other tests for >> permissions or ownership. >> >>> On Thu, Mar 4, 2010 at 12:06 PM, Patrick <kc7zzv@gmail.com> wrote: >>>> >>>> On Mar 4, 2010, at 7:29 AM, Allan Marcus wrote: >>>> >>>>> A file that this command creates. If this >>>>> parameter is provided, then the command will only be run >>>>> if the specified file does not exist:: >>>>> >>>>> exec { \"tar xf /my/tar/file.tar\": >>>>> cwd => \"/var/tmp\", >>>>> creates => \"/var/tmp/myfile\", >>>>> path => [\"/usr/bin\", \"/usr/sbin\"] >>>>> } >>>>> >>>>> >>>>> Is there a way to set the content of this file (/var/tmp/myfile) using some additional parameter in the above syntax? >>>> >>>> This isn''t the "right" way to do it, and you may have performance issues depending on the size of the file, but you can always combine grep with unless. >>>> >>>> If you want to re-extract the file if the file doesn''t contain "testString" this should work. >>>> >>>> exec { "tar xf /my/tar/file.tar": >>>> cwd => "/var/tmp", >>>> creates => "/var/tmp/myfile", >>>> path => ["/usr/bin", "/usr/sbin"], >>>> unless => "grep testString myfile", >>>> } >>>> >>>> >>>> -- >>>> 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. >>> >> >> -- >> 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. >-- 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.