Hi, I''m trying to manage war files on several tomcat servers. Here is
what I''m trying to do:
I have a source directory with war files that I want to sync to the
nodes. The nodes mount this directory via nfs.
When a change is detected I want to copy the war files from the nfs
share to /webapps, stop tomcat, remove any directories in /webapps and
restart tomcat.
The part that is hanging me up is the use of the file resource on
directories. It does not seem to copy the files. I can get it to work
if I use it for 1 file but not the whole directory. Here is my def:
# make sure the NFS directory is mounted under /dist
class prep_puppet_nfs {
file { nfs-dist:
name => "/dist",
ensure => directory,
}
mount { puppet-nfs:
ensure => mounted,
device => "$servername:/etc/puppet/dist/packages",
fstype => "nfs",
options => "ro",
name => "/dist",
subscribe => File[nfs-dist]
}
}
define war_download($tomcat_version, $subdir) {
$tomcat_major_v = $tomcat_version ? {
"6.0.18" => "6",
default => "6",
}
file { "/home/tomcat/apache-tomcat-$tomcat_version/webapps":
source => "/dist/tomcat-wars/$subdir",
owner => "tomcat",
group => "tomcat",
recurse => 1,
checksum => md5,
replace => true;
}
exec { stop_tomcat_war:
command => "/sbin/service tomcat$tomcat_major_v stop",
path => "/usr/bin:/usr/sbin:/bin",
user => root,
group => root,
refreshonly => true,
subscribe => File["/home/tomcat/apache-tomcat-$tomcat_version/
webapps"],
}
exec { remove_war_dir:
# removes just directories
command => "find /home/tomcat/apache-tomcat-$tomcat_version/
webapps/* -type d | awk ''/.\//'' | xargs rm -rf",
cwd => "/home/tomcat/apache-tomcat-$tomcat_version/webapps",
path => "/usr/bin:/usr/sbin:/bin",
user => root,
group => root,
subscribe => Exec[''stop_tomcat_war''],
}
exec { start_tomcat_war:
command => "/sbin/service tomcat$tomcat_major_v start",
path => "/usr/bin:/usr/sbin:/bin",
user => root,
group => root,
subscribe => Exec[''remove_war_dir''],
}
}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
What behavior are you getting? The recurse => 1 means it should only get the first level of that directory, I think you want recurse => true. On Wed, Sep 17, 2008 at 5:02 PM, pfleming <prc368@motorola.com> wrote:> > Hi, I''m trying to manage war files on several tomcat servers. Here is > what I''m trying to do: > > I have a source directory with war files that I want to sync to the > nodes. The nodes mount this directory via nfs. > When a change is detected I want to copy the war files from the nfs > share to /webapps, stop tomcat, remove any directories in /webapps and > restart tomcat. > > The part that is hanging me up is the use of the file resource on > directories. It does not seem to copy the files. I can get it to work > if I use it for 1 file but not the whole directory. Here is my def: > > # make sure the NFS directory is mounted under /dist > class prep_puppet_nfs { > file { nfs-dist: > name => "/dist", > ensure => directory, > } > mount { puppet-nfs: > ensure => mounted, > device => "$servername:/etc/puppet/dist/packages", > fstype => "nfs", > options => "ro", > name => "/dist", > subscribe => File[nfs-dist] > } > } > > define war_download($tomcat_version, $subdir) { > > $tomcat_major_v = $tomcat_version ? { > "6.0.18" => "6", > default => "6", > } > > file { "/home/tomcat/apache-tomcat-$tomcat_version/webapps": > source => "/dist/tomcat-wars/$subdir", > owner => "tomcat", > group => "tomcat", > recurse => 1, > checksum => md5, > replace => true; > } > > exec { stop_tomcat_war: > command => "/sbin/service tomcat$tomcat_major_v stop", > path => "/usr/bin:/usr/sbin:/bin", > user => root, > group => root, > refreshonly => true, > subscribe => File["/home/tomcat/apache-tomcat-$tomcat_version/ > webapps"], > } > > exec { remove_war_dir: > # removes just directories > command => "find /home/tomcat/apache-tomcat-$tomcat_version/ > webapps/* -type d | awk ''/.\//'' | xargs rm -rf", > cwd => "/home/tomcat/apache-tomcat-$tomcat_version/webapps", > path => "/usr/bin:/usr/sbin:/bin", > user => root, > group => root, > subscribe => Exec[''stop_tomcat_war''], > } > > exec { start_tomcat_war: > command => "/sbin/service tomcat$tomcat_major_v start", > path => "/usr/bin:/usr/sbin:/bin", > user => root, > group => root, > subscribe => Exec[''remove_war_dir''], > } > > } > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 Sep 17, 7:02 pm, pfleming <prc...@motorola.com> wrote:> Hi, I''m trying to manage war files on several tomcat servers. Here is > what I''m trying to do: > > I have a source directory with war files that I want to sync to the > nodes. The nodes mount this directory via nfs. > When a change is detected I want to copy the war files from the nfs > share to /webapps, stop tomcat, remove any directories in /webapps and > restart tomcat.I don''t know about everyone else, but I would probably write a script (Perl, Ruby, Bash) to do the actual stop/move files/start process. While the puppet method seems to work for you, I would think that maintaining it would be a nightmare. Script programming would probably be much more clean and maintainable for other people on the team. I *would* use Puppet to sync the script and to fire it off, just not do all the work. Any thoughts? Later... Richard --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Richard, Please elaborate on what you believe would be harder to maintain than the script. On Thu, Sep 18, 2008 at 5:00 AM, Richard <rnhurt@gmail.com> wrote:> > On Sep 17, 7:02 pm, pfleming <prc...@motorola.com> wrote: > > Hi, I''m trying to manage war files on several tomcat servers. Here is > > what I''m trying to do: > > > > I have a source directory with war files that I want to sync to the > > nodes. The nodes mount this directory via nfs. > > When a change is detected I want to copy the war files from the nfs > > share to /webapps, stop tomcat, remove any directories in /webapps and > > restart tomcat. > > I don''t know about everyone else, but I would probably write a script > (Perl, Ruby, Bash) to do the actual stop/move files/start process. > While the puppet method seems to work for you, I would think that > maintaining it would be a nightmare. Script programming would > probably be much more clean and maintainable for other people on the > team. I *would* use Puppet to sync the script and to fire it off, > just not do all the work. Any thoughts? > > Later... > Richard > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
It looks like puppet detects a change in mtime (although I specified
md5) and runs the dependencies but does not copy the files.
Thanks,
Pete
________________________________
From: puppet-users@googlegroups.com
[mailto:puppet-users@googlegroups.com] On Behalf Of Andrew Shafer
Sent: Wednesday, September 17, 2008 9:42 PM
To: puppet-users@googlegroups.com
Subject: [Puppet Users] Re: managing war files
What behavior are you getting?
The recurse => 1 means it should only get the first level of that
directory, I think you want recurse => true.
On Wed, Sep 17, 2008 at 5:02 PM, pfleming <prc368@motorola.com> wrote:
Hi, I''m trying to manage war files on several tomcat servers.
Here is
what I''m trying to do:
I have a source directory with war files that I want to sync to
the
nodes. The nodes mount this directory via nfs.
When a change is detected I want to copy the war files from the
nfs
share to /webapps, stop tomcat, remove any directories in
/webapps and
restart tomcat.
The part that is hanging me up is the use of the file resource
on
directories. It does not seem to copy the files. I can get it to
work
if I use it for 1 file but not the whole directory. Here is my
def:
# make sure the NFS directory is mounted under /dist
class prep_puppet_nfs {
file { nfs-dist:
name => "/dist",
ensure => directory,
}
mount { puppet-nfs:
ensure => mounted,
device => "$servername:/etc/puppet/dist/packages",
fstype => "nfs",
options => "ro",
name => "/dist",
subscribe => File[nfs-dist]
}
}
define war_download($tomcat_version, $subdir) {
$tomcat_major_v = $tomcat_version ? {
"6.0.18" => "6",
default => "6",
}
file { "/home/tomcat/apache-tomcat-$tomcat_version/webapps":
source => "/dist/tomcat-wars/$subdir",
owner => "tomcat",
group => "tomcat",
recurse => 1,
checksum => md5,
replace => true;
}
exec { stop_tomcat_war:
command => "/sbin/service tomcat$tomcat_major_v stop",
path => "/usr/bin:/usr/sbin:/bin",
user => root,
group => root,
refreshonly => true,
subscribe =>
File["/home/tomcat/apache-tomcat-$tomcat_version/
webapps"],
}
exec { remove_war_dir:
# removes just directories
command => "find /home/tomcat/apache-tomcat-$tomcat_version/
webapps/* -type d | awk ''/.\//'' | xargs rm -rf",
cwd => "/home/tomcat/apache-tomcat-$tomcat_version/webapps",
path => "/usr/bin:/usr/sbin:/bin",
user => root,
group => root,
subscribe => Exec[''stop_tomcat_war''],
}
exec { start_tomcat_war:
command => "/sbin/service tomcat$tomcat_major_v start",
path => "/usr/bin:/usr/sbin:/bin",
user => root,
group => root,
subscribe => Exec[''remove_war_dir''],
}
}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---