Michael Baydoun
2012-Jun-20 17:29 UTC
[Puppet Users] puppet windows exec successful but not really
have the following in my manifest to delete old uninstall directories and logs using exec since we don''t have tidy for windows yet {code} exec { ''CleanupOldUninstallDirs'': command => ''C:\Windows\system32\forfiles.exe -p "C:\Windows" -m "$NtUninstall*" -d -65 -c "cmd /c dev /F /S /Q @path"'', } exec { ''CleanupOldPatchLogs'': command => ''C:\Windows\system32\forfiles.exe -p "C:\Windows" -m "KB*.log" -d -365 -c "cmd /c dev /F /S /Q @path"'', } {code} runs correctly debug output below [image: Inline image 1] however, files are not deleted, as evidenced by running the same forfiles at the command line [image: Inline image 2] yet the forfiles with delete works if I run it from the windows command line Suggestions? Bug? -- 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.
Josh Cooper
2012-Jun-20 19:38 UTC
Re: [Puppet Users] puppet windows exec successful but not really
Hi Michael, On Wed, Jun 20, 2012 at 10:29 AM, Michael Baydoun <indymichaelb@gmail.com>wrote:> have the following in my manifest to delete old uninstall directories and > logs > using exec since we don''t have tidy for windows yet > > {code} > exec { ''CleanupOldUninstallDirs'': > command => ''C:\Windows\system32\forfiles.exe -p "C:\Windows" -m > "$NtUninstall*" -d -65 -c "cmd /c dev /F /S /Q @path"'', > } > exec { ''CleanupOldPatchLogs'': > command => ''C:\Windows\system32\forfiles.exe -p "C:\Windows" -m > "KB*.log" -d -365 -c "cmd /c dev /F /S /Q @path"'', > } > {code} > > runs correctly debug output below > [image: Inline image 1] > > however, files are not deleted, as evidenced by running the same forfiles > at the command line > > [image: Inline image 2] > > yet the forfiles with delete works if I run it from the windows command > line > > Suggestions? Bug? > > > -- > 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 this is a 64-bit OS, then I''m guessing it''s an issue with filesystem redirection. Ruby is a 32-bit app, so any filesystem access to c:\windows\system32 is redirected to c:\windows\syswow64. You can avoid this by specifying c:\windows\sysnative instead. Josh -- Josh Cooper Developer, Puppet Labs -- 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.
Michael Baydoun
2012-Jun-22 17:33 UTC
Re: [Puppet Users] puppet windows exec successful but not really
My windows client is running Windows 2003 Server 32 bit On Wed, Jun 20, 2012 at 3:38 PM, Josh Cooper <josh@puppetlabs.com> wrote:> Hi Michael, > > On Wed, Jun 20, 2012 at 10:29 AM, Michael Baydoun <indymichaelb@gmail.com>wrote: > >> have the following in my manifest to delete old uninstall directories and >> logs >> using exec since we don''t have tidy for windows yet >> >> {code} >> exec { ''CleanupOldUninstallDirs'': >> command => ''C:\Windows\system32\forfiles.exe -p "C:\Windows" -m >> "$NtUninstall*" -d -65 -c "cmd /c dev /F /S /Q @path"'', >> } >> exec { ''CleanupOldPatchLogs'': >> command => ''C:\Windows\system32\forfiles.exe -p "C:\Windows" -m >> "KB*.log" -d -365 -c "cmd /c dev /F /S /Q @path"'', >> } >> {code} >> >> runs correctly debug output below >> [image: Inline image 1] >> >> however, files are not deleted, as evidenced by running the same forfiles >> at the command line >> >> [image: Inline image 2] >> >> yet the forfiles with delete works if I run it from the windows command >> line >> >> Suggestions? Bug? >> >> >> -- >> 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 this is a 64-bit OS, then I''m guessing it''s an issue with filesystem > redirection. Ruby is a 32-bit app, so any filesystem access to > c:\windows\system32 is redirected to c:\windows\syswow64. You can avoid > this by specifying c:\windows\sysnative instead. > > Josh > > -- > Josh Cooper > Developer, Puppet Labs > > -- > 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.
Josh Cooper
2012-Jun-22 18:00 UTC
Re: [Puppet Users] puppet windows exec successful but not really
Hi Michael On Fri, Jun 22, 2012 at 10:33 AM, Michael Baydoun <indymichaelb@gmail.com>wrote:> My windows client is running Windows 2003 Server 32 bit > > > On Wed, Jun 20, 2012 at 3:38 PM, Josh Cooper <josh@puppetlabs.com> wrote: > >> Hi Michael, >> >> On Wed, Jun 20, 2012 at 10:29 AM, Michael Baydoun <indymichaelb@gmail.com >> > wrote: >> >>> have the following in my manifest to delete old uninstall directories >>> and logs >>> using exec since we don''t have tidy for windows yet >>> >>> {code} >>> exec { ''CleanupOldUninstallDirs'': >>> command => ''C:\Windows\system32\forfiles.exe -p "C:\Windows" >>> -m "$NtUninstall*" -d -65 -c "cmd /c dev /F /S /Q @path"'', >>> } >>> exec { ''CleanupOldPatchLogs'': >>> command => ''C:\Windows\system32\forfiles.exe -p "C:\Windows" >>> -m "KB*.log" -d -365 -c "cmd /c dev /F /S /Q @path"'', >>> } >>> {code} >>> >>Puppet requires that exec resources return non-zero exit status if the command fails. If I run the following, it still returns 0: C:\>forfiles -p c:\windows -m "$NtUninstall*" -d -65 -c "cmd /c foo" ''foo'' is not recognized as an internal or external command, operable program or batch file. ... C:\>echo %ERRORLEVEL% 0 I think the issue is that dev is in your PATH when run from the command line, but is not in the PATH that puppet is running with. Try specifying the `path` parameter in your exec resources, e.g. path => ''c:\windows\system32;c:\windows;c:\path\to\dev;etc''>>> runs correctly debug output below >>> [image: Inline image 1] >>> >>> however, files are not deleted, as evidenced by running the same >>> forfiles at the command line >>> >>> [image: Inline image 2] >>> >>> yet the forfiles with delete works if I run it from the windows command >>> line >>> >>> Suggestions? Bug? >>> >>> >>> -- >>> 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 this is a 64-bit OS, then I''m guessing it''s an issue with filesystem >> redirection. Ruby is a 32-bit app, so any filesystem access to >> c:\windows\system32 is redirected to c:\windows\syswow64. You can avoid >> this by specifying c:\windows\sysnative instead. >> >> Josh >> >> -- >> Josh Cooper >> Developer, Puppet Labs >> >> -- >> 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. >-- Josh Cooper Developer, Puppet Labs -- 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.
Josh Cooper
2012-Jun-22 19:05 UTC
Re: [Puppet Users] puppet windows exec successful but not really
Hi Michael, On Fri, Jun 22, 2012 at 11:00 AM, Josh Cooper <josh@puppetlabs.com> wrote:> > Hi Michael > > On Fri, Jun 22, 2012 at 10:33 AM, Michael Baydoun <indymichaelb@gmail.com> wrote: >> >> My windows client is running Windows 2003 Server 32 bit >> >> >> On Wed, Jun 20, 2012 at 3:38 PM, Josh Cooper <josh@puppetlabs.com> wrote: >>> >>> Hi Michael, >>> >>> On Wed, Jun 20, 2012 at 10:29 AM, Michael Baydoun <indymichaelb@gmail.com> wrote: >>>> >>>> have the following in my manifest to delete old uninstall directories and logs >>>> using exec since we don''t have tidy for windows yet >>>> >>>> {code} >>>> exec { ''CleanupOldUninstallDirs'': >>>> command => ''C:\Windows\system32\forfiles.exe -p "C:\Windows" -m "$NtUninstall*" -d -65 -c "cmd /c dev /F /S /Q @path"'', >>>> } >>>> exec { ''CleanupOldPatchLogs'': >>>> command => ''C:\Windows\system32\forfiles.exe -p "C:\Windows" -m "KB*.log" -d -365 -c "cmd /c dev /F /S /Q @path"'', >>>> } >>>> {code} > > > Puppet requires that exec resources return non-zero exit status if the command fails. If I run the following, it still returns 0: > > C:\>forfiles -p c:\windows -m "$NtUninstall*" -d -65 -c "cmd /c foo" > ''foo'' is not recognized as an internal or external command, > operable program or batch file. > ... > C:\>echo %ERRORLEVEL% > 0 > > I think the issue is that dev is in your PATH when run from the command line, but is not in the PATH that puppet is running with. Try specifying the `path` parameter in your exec resources, e.g. > > path => ''c:\windows\system32;c:\windows;c:\path\to\dev;etc'' >Or is that a typo? Should that be `del` instead of `dev`?>>>> >>>> runs correctly debug output below >>>> >>>> >>>> however, files are not deleted, as evidenced by running the same forfiles at the command line >>>> >>>> >>>> >>>> yet the forfiles with delete works if I run it from the windows command line >>>> >>>> Suggestions? Bug? >>>> >>>> >>>> -- >>>> 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 this is a 64-bit OS, then I''m guessing it''s an issue with filesystem redirection. Ruby is a 32-bit app, so any filesystem access to c:\windows\system32 is redirected to c:\windows\syswow64. You can avoid this by specifying c:\windows\sysnative instead. >>> >>> Josh >>> >>> -- >>> Josh Cooper >>> Developer, Puppet Labs >>> >>> -- >>> 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. > > > > > -- > Josh Cooper > Developer, Puppet Labs >-- Josh Cooper Developer, Puppet Labs -- 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.
Michael Baydoun
2012-Jun-22 19:27 UTC
Re: [Puppet Users] puppet windows exec successful but not really
yes <hides head in shame>, that''s a typo. Working now, thanks! Too bad it returns 0 all the time. On Fri, Jun 22, 2012 at 3:05 PM, Josh Cooper <josh@puppetlabs.com> wrote:> Hi Michael, > > On Fri, Jun 22, 2012 at 11:00 AM, Josh Cooper <josh@puppetlabs.com> wrote: > > > > Hi Michael > > > > On Fri, Jun 22, 2012 at 10:33 AM, Michael Baydoun < > indymichaelb@gmail.com> wrote: > >> > >> My windows client is running Windows 2003 Server 32 bit > >> > >> > >> On Wed, Jun 20, 2012 at 3:38 PM, Josh Cooper <josh@puppetlabs.com> > wrote: > >>> > >>> Hi Michael, > >>> > >>> On Wed, Jun 20, 2012 at 10:29 AM, Michael Baydoun < > indymichaelb@gmail.com> wrote: > >>>> > >>>> have the following in my manifest to delete old uninstall directories > and logs > >>>> using exec since we don''t have tidy for windows yet > >>>> > >>>> {code} > >>>> exec { ''CleanupOldUninstallDirs'': > >>>> command => ''C:\Windows\system32\forfiles.exe -p > "C:\Windows" -m "$NtUninstall*" -d -65 -c "cmd /c dev /F /S /Q @path"'', > >>>> } > >>>> exec { ''CleanupOldPatchLogs'': > >>>> command => ''C:\Windows\system32\forfiles.exe -p > "C:\Windows" -m "KB*.log" -d -365 -c "cmd /c dev /F /S /Q @path"'', > >>>> } > >>>> {code} > > > > > > Puppet requires that exec resources return non-zero exit status if the > command fails. If I run the following, it still returns 0: > > > > C:\>forfiles -p c:\windows -m "$NtUninstall*" -d -65 -c "cmd /c foo" > > ''foo'' is not recognized as an internal or external command, > > operable program or batch file. > > ... > > C:\>echo %ERRORLEVEL% > > 0 > > > > I think the issue is that dev is in your PATH when run from the command > line, but is not in the PATH that puppet is running with. Try specifying > the `path` parameter in your exec resources, e.g. > > > > path => ''c:\windows\system32;c:\windows;c:\path\to\dev;etc'' > > > > Or is that a typo? Should that be `del` instead of `dev`? > > >>>> > >>>> runs correctly debug output below > >>>> > >>>> > >>>> however, files are not deleted, as evidenced by running the same > forfiles at the command line > >>>> > >>>> > >>>> > >>>> yet the forfiles with delete works if I run it from the windows > command line > >>>> > >>>> Suggestions? Bug? > >>>> > >>>> > >>>> -- > >>>> 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 this is a 64-bit OS, then I''m guessing it''s an issue with > filesystem redirection. Ruby is a 32-bit app, so any filesystem access to > c:\windows\system32 is redirected to c:\windows\syswow64. You can avoid > this by specifying c:\windows\sysnative instead. > >>> > >>> Josh > >>> > >>> -- > >>> Josh Cooper > >>> Developer, Puppet Labs > >>> > >>> -- > >>> 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. > > > > > > > > > > -- > > Josh Cooper > > Developer, Puppet Labs > > > > > > -- > Josh Cooper > Developer, Puppet Labs > > -- > 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.
Seemingly Similar Threads
- Puppet logging
- Windows Remote Desktop Services (Could not find a suitable provider for dism)
- Different return codes on exec during puppet agent run vs command line Windows
- RODBC for 64-bit R with 32-bit Access
- RODBC Access/Excel driver location for 64 bit Win7