On Thursday, April 11, 2013 1:11:16 PM UTC-5, Rahul Khengare wrote:
>
> Hi all,
>      I am writing two modules abc and xyz. In both the modules i have to 
> change common "test.txt" file,here i use template (.erb) file to changing 
> the contents.
> In both abc and xyz the contents of "test.txt" file is different, if i 
> declare file resource for "test.txt" file in two different modules it gives 
> duplicate declaration of resource error. 
> For the correct working of modules abc and xyz, i have to change the 
> test.txt file twice.
> How i overcome this situation ?       
>


You need to frame the problem correctly.  A File resource represents a 
whole, specific file.  What is it even supposed to mean if you specify the 
same target file's content differently in different places?  Your two 
declarations cannot both be satisfied.  This sort of internal inconsistency 
is one of the reasons for Puppet's prohibition against multiple 
declarations of the same resource (though that prohibition applies even 
when two or more declarations all specify exactly the same parameters).

There are at least two different things you could reasonably mean:


   1. Most likely, you mean that you want to separately describe two or 
   more different parts of the same file.  In that case you are incorrect to 
   model the parts as File resources, because they are not whole files.  There 
   are multiple ways to handle this, but a good one would be via the Concat 
   module, which you can find on the module forge.  It will allow you to model 
   individual pieces of a file, and to specify how they are to be assembled to 
   form the whole.
   2. You could mean that you want to declare separate files whose contents 
   are based on the same template.  In that case it is correct to use separate 
   File resources, but you must be declaring them wrongly.  Each one must have 
   a unique title and a unique absolute filename (path property); if not 
   specified explicitly, the absolute filename is the same as the title.  
   There is no inherent need for the resource title or target file name to 
   have any particular relationship with the template file name (though you 
   will make it easier on yourself if you choose something that helps you 
   associate them).
   

Good luck,

John

-- 
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+unsubscr...@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.


Reply via email to