Hi, I am creating a file resouce which is bat file, and I am running the file to perform some operation. I need to know how do I delete the file after the operation is performed... the code I tried is as follows class rk{ file { "c:\install.bat": ensure => present, content => template("rk/inst.txt"), notify => Exec[''install''] } exec {''install'': command => "c:\install.bat", timeout => 0, require => File[''c:\install.bat''], } file { "c:\install.bat": ensure => absent, } } Now it gives me a duplicate declaration error for resource file.... I understand its very logical to get this error but can someone please give some pointers to resolve this issue. Thanks a lot. Rakesh K. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
You could try: file { ''delete-install-bat'': ensure => absent, path => ''c:\install.bat'', require => Exec[''install''], } Cheers, Bernd From: puppet-users@googlegroups.com [mailto:puppet-users@googlegroups.com] On Behalf Of Rakesh Kathpal Sent: Dienstag, 19. Februar 2013 15:22 To: puppet-users@googlegroups.com Subject: [Puppet Users] Question Windows manifests Hi, I am creating a file resouce which is bat file, and I am running the file to perform some operation. I need to know how do I delete the file after the operation is performed... the code I tried is as follows class rk{ file { "c:\install.bat": ensure => present, content => template("rk/inst.txt"), notify => Exec[''install''] } exec {''install'': command => "c:\install.bat", timeout => 0, require => File[''c:\install.bat''], } file { "c:\install.bat": ensure => absent, } } Now it gives me a duplicate declaration error for resource file.... I understand its very logical to get this error but can someone please give some pointers to resolve this issue. Thanks a lot. Rakesh K. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com<mailto:puppet-users+unsubscribe@googlegroups.com>. To post to this group, send email to puppet-users@googlegroups.com<mailto:puppet-users@googlegroups.com>. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
thanks a ton.. I will give it try and revert... On Tue, Feb 19, 2013 at 7:58 PM, Bernd Adamowicz < Bernd.Adamowicz@esailors.de> wrote:> You could try:**** > > ** ** > > > file { ‘delete-install-bat’: > ensure => absent,**** > > path => ‘c:\install.bat’,**** > > require => Exec[‘install’], > }**** > > ** ** > > Cheers,**** > > Bernd**** > > *From:* puppet-users@googlegroups.com [mailto: > puppet-users@googlegroups.com] *On Behalf Of *Rakesh Kathpal > *Sent:* Dienstag, 19. Februar 2013 15:22 > *To:* puppet-users@googlegroups.com > *Subject:* [Puppet Users] Question Windows manifests**** > > ** ** > > Hi, > > I am creating a file resouce which is bat file, and I am running the file > to perform some operation. > > I need to know how do I delete the file after the operation is > performed... the code I tried is as follows > > class rk{ > > file { "c:\install.bat": > ensure => present, > content => template("rk/inst.txt"), > notify => Exec[''install''] > } > exec {''install'': > command => "c:\install.bat", > timeout => 0, > require => File[''c:\install.bat''], > } > > file { "c:\install.bat": > ensure => absent, > } > } > > Now it gives me a duplicate declaration error for resource file.... I > understand its very logical to get this error but can someone please give > some pointers to resolve this issue. > > Thanks a lot. > > Rakesh K.**** > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to puppet-users+unsubscribe@googlegroups.com. > To post to this group, send email to puppet-users@googlegroups.com. > Visit this group at http://groups.google.com/group/puppet-users?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > **** > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to puppet-users+unsubscribe@googlegroups.com. > To post to this group, send email to puppet-users@googlegroups.com. > Visit this group at http://groups.google.com/group/puppet-users?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
unfortunately getting a different error now ---------------------------- err: Failed to apply catalog: Cannot alias File[install] to ["c:/install.bat"] at /etc/puppet/modules/rk/manifests/init.pp:8; resource ["File", "c:/install.bat"] already declared at /etc/puppet/modules/rk/manifests/init.pp:20 --------------------------- my manifests looks like follows -------------------------------------------------- class rk { file { ''install'': path => "c:\install.bat", ensure => present, content => template("rk/inst.txt"), notify => Exec[''install_sw''] } exec {''install_sw'': command => "c:\install.bat", timeout => 0, require => File[''install''], notify => File[''remove''] } file { ''remove'': ensure => absent, path => "c:\install.bat", require => Exec[''install_sw''] } } ----------------------------------------------- I am quite sure that there is something syntactically wrong my code but donno what? Can someone please shed some light on this? Thanks & Regards, Rakesh K. On Wed, Feb 20, 2013 at 10:32 AM, Rakesh Kathpal <rkathpal@gmail.com> wrote:> thanks a ton.. I will give it try and revert... > > > On Tue, Feb 19, 2013 at 7:58 PM, Bernd Adamowicz < > Bernd.Adamowicz@esailors.de> wrote: > >> You could try:**** >> >> ** ** >> >> >> file { ‘delete-install-bat’: >> ensure => absent,**** >> >> path => ‘c:\install.bat’,**** >> >> require => Exec[‘install’], >> }**** >> >> ** ** >> >> Cheers,**** >> >> Bernd**** >> >> *From:* puppet-users@googlegroups.com [mailto: >> puppet-users@googlegroups.com] *On Behalf Of *Rakesh Kathpal >> *Sent:* Dienstag, 19. Februar 2013 15:22 >> *To:* puppet-users@googlegroups.com >> *Subject:* [Puppet Users] Question Windows manifests**** >> >> ** ** >> >> Hi, >> >> I am creating a file resouce which is bat file, and I am running the file >> to perform some operation. >> >> I need to know how do I delete the file after the operation is >> performed... the code I tried is as follows >> >> class rk{ >> >> file { "c:\install.bat": >> ensure => present, >> content => template("rk/inst.txt"), >> notify => Exec[''install''] >> } >> exec {''install'': >> command => "c:\install.bat", >> timeout => 0, >> require => File[''c:\install.bat''], >> } >> >> file { "c:\install.bat": >> ensure => absent, >> } >> } >> >> Now it gives me a duplicate declaration error for resource file.... I >> understand its very logical to get this error but can someone please give >> some pointers to resolve this issue. >> >> Thanks a lot. >> >> Rakesh K.**** >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Puppet Users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to puppet-users+unsubscribe@googlegroups.com. >> To post to this group, send email to puppet-users@googlegroups.com. >> Visit this group at http://groups.google.com/group/puppet-users?hl=en. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> **** >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Puppet Users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to puppet-users+unsubscribe@googlegroups.com. >> To post to this group, send email to puppet-users@googlegroups.com. >> Visit this group at http://groups.google.com/group/puppet-users?hl=en. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Hi, On 02/20/2013 06:43 AM, Rakesh Kathpal wrote:> file { ''install'': > path => "c:\install.bat",...> exec {''install_sw'': > file { ''remove'': > ensure => absent,...> I am quite sure that there is something > syntactically wrong my code but donno what? Can someone please shed some > light on this?Actually, sorry to say this, but there''s something conceptually wrong with this. You''re walking into the "C-like programming language" trap. The thing is - the puppet DSL is nothing like traditional, statement based programming. The above are not three statements that are executed in order. They are supposed to be three properties of system state. You are telling puppet that you want it to make sure three things hold true: 1. c:\install.bat is present and has specific content 2. c:\install.bat is getting executed 3. c:\install.bat is not on your system 1 and 3 are conflicting. Puppet cannot maintain a state in which both are true. You will have a hard time bending puppet towards this behaviour. I suggest you just get rid of the final file resource and let the install.bat remain (but do choose a location that is better suited to store such internal administrative data). Also please note that you probably either want to add "refreshonly" to your exec resource, but that is rather unclean design (if the execution fails once, puppet will not know it needs to re-run because the file will not notify it again). The better alternative is a sensible "creates" or "unless" condition. HTH, Felix -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Dear Felix, Thanks a ton for your reply and great piece of information. I will do the needful on my side. Thanks again, Regards, Rakesh K. On Wed, Feb 20, 2013 at 3:41 PM, Felix Frank < felix.frank@alumni.tu-berlin.de> wrote:> Hi, > > On 02/20/2013 06:43 AM, Rakesh Kathpal wrote: > > file { ''install'': > > path => "c:\install.bat", > ... > > exec {''install_sw'': > > file { ''remove'': > > ensure => absent, > ... > > I am quite sure that there is something > > syntactically wrong my code but donno what? Can someone please shed some > > light on this? > > Actually, sorry to say this, but there''s something conceptually wrong > with this. > > You''re walking into the "C-like programming language" trap. The thing is > - the puppet DSL is nothing like traditional, statement based > programming. The above are not three statements that are executed in > order. They are supposed to be three properties of system state. > > You are telling puppet that you want it to make sure three things hold > true: > 1. c:\install.bat is present and has specific content > 2. c:\install.bat is getting executed > 3. c:\install.bat is not on your system > > 1 and 3 are conflicting. Puppet cannot maintain a state in which both > are true. You will have a hard time bending puppet towards this behaviour. > > I suggest you just get rid of the final file resource and let the > install.bat remain (but do choose a location that is better suited to > store such internal administrative data). > > Also please note that you probably either want to add "refreshonly" to > your exec resource, but that is rather unclean design (if the execution > fails once, puppet will not know it needs to re-run because the file > will not notify it again). > The better alternative is a sensible "creates" or "unless" condition. > > HTH, > Felix > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to puppet-users+unsubscribe@googlegroups.com. > To post to this group, send email to puppet-users@googlegroups.com. > Visit this group at http://groups.google.com/group/puppet-users?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.