[Puppet Users] Re: Copying multiple files to multiple locations

2013-08-13 Thread jcbollinger


On Friday, August 9, 2013 9:06:42 AM UTC-5, Matthijs Suringa wrote:
>
> Hi,
>
> I'm, still relatively new to Puppet, so there might be something I am 
> overlooking.
> Anyway, my situation is that I can install 1 or multiple tomcat instances 
> on a machine, and in order for me to ensure that they can talk to all 
> databases we run (test environments) I want to copy all DB drivers into 
> each instance.
>
> So basically I have a defined type for my tomcat instance, which does the 
> installation of the tomcat binaries and configured the necessary files. Per 
> instance I need to copy X files into the lib directory.
> I wanted to do this with another defined type, so I could "loop" through 
> an array of DB-drivers. However, because both instances would require the 
> same files, I am running into the "duplicate declaration" error.
>
> Is there any way to resolve this issue?
>
>

I think you are saying that for each Tomcat instance you want to ensure the 
same files present in the same directory (rather than in distinct, 
instance-specific directories).  The key problem with your approach to that 
is you are trying to manage the driver files as if they belong to 
individual instances, whereas they actually belong to Tomcat overall.

The available solutions fall into two categories:

   1. Give each Tomcat instance its own, separate copies of the files.
   2. Factor the affected file resources out of your Tomcat instance 
   definition, and instead manage them in one central place for all 
   instances.  The most likely way to do this would be to put them into a 
   class that the instance definition declares (which works because Puppet 
   classes are idempotent).

Example:

class tomcat::db_drivers {
  include 'tomcat'
  file { "$tomcat_root/lib/mysql.jar":
ensure => 'present',
source => 'puppet://modules/tomcat/mysql.jar'
  }
  ...
}

define tomcat::instance(...) {
  include 'tomcat'
  include 'tomcat::db_drivers'

  # instance-specific resources ...
}


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.
For more options, visit https://groups.google.com/groups/opt_out.




[Puppet Users] Re: Copying multiple files to multiple locations

2013-08-12 Thread Rahul Khengare
Hi Matthijs,
  You can try using array variable in file resource.This may solve your 
issue. Can you explain in detail. I mean the location of files and 
directory structures.

If you want to copy the same file content in several files refer following 
code snippet,You can use various files path  in array.
$file_names = ['/root/t1',/root/t2',/root/t3',/root/t4']

file { $file_names:
  ensure => file,
  content => 'xyz',
}

You can also use source => '/root/xyz.txt' tag/attribute of file resource 
for coping whole file.
This copied the 'xyz' content in all the files present in $file_name array 
variables.


Thanks & Regards,
Rahul Khengare,

NTT DATA OSS Center Pune, India.**





On Friday, August 9, 2013 7:36:42 PM UTC+5:30, Matthijs Suringa wrote:
>
> Hi,
>
> I'm, still relatively new to Puppet, so there might be something I am 
> overlooking.
> Anyway, my situation is that I can install 1 or multiple tomcat instances 
> on a machine, and in order for me to ensure that they can talk to all 
> databases we run (test environments) I want to copy all DB drivers into 
> each instance.
>
> So basically I have a defined type for my tomcat instance, which does the 
> installation of the tomcat binaries and configured the necessary files. Per 
> instance I need to copy X files into the lib directory.
> I wanted to do this with another defined type, so I could "loop" through 
> an array of DB-drivers. However, because both instances would require the 
> same files, I am running into the "duplicate declaration" error.
>
> Is there any way to resolve this issue?
> Thanks
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.