Reputation: 320
I'm trying deploy a War file on my Tomcat 7 installed by a cookbook on CHEF. But, I can't find a single answer for my question at any forums. I don't have any idea how to do this! I'm using a Ubuntu server 12.10. The recipe that I'm using is https://github.com/solarvm/tomcat7-cookbook
Upvotes: 2
Views: 8288
Reputation: 53
A very important part to remember while doing this in chef is to use a guard conditions to not let chef keep deploying the file on every run. As the steps explained above are fine but when you code in chef, it will keep copying the file in each run and deploying unless you have a guard condition.
Take for example below case, chef will execute this in each run.
# Extract
execute "tar" do
user "#{tc7user}"
group "#{tc7group}"
installation_dir = "#{tc7target}"
cwd installation_dir
command "tar zxf /tmp/#{tc7tarball}"
action :run
end
To prevent chef from executing the on each run use the creates
property with parameter of the full path of the file being created. The next chef run will see that file was already created and will skip it.
Upvotes: 0
Reputation: 718798
The simple way to do is is to use the service
resource to stop Tomcat, use the bash
resource or a file resource to copy the WAR file, and then use the service
resource to start Tomcat again.
That cookbook you are trying to use doesn't do WAR file deployment. But I found this one - https://github.com/poise/application_java - that may do the job.
And for what it is worth, I think you could find a better Tomcat installation cookbook too. For a start, there is a "tomcat" recipe on the Opscode Community Cookbooks site that can handle Tomcat 7.
(Hint: don't just use the first cookbook you find with Google. Do a Github search, and try to assess the cookbooks functionality and quality)
Upvotes: 2
Reputation: 10400
Have you already found $tomcat/webapps/ folder?
Steps doing a manual hotdeployment and update. Avoiding possible conflict you should do a temporary mywebapp.war.zip filename trick. Trick I have used in linux and windows for years.
http://localhost:8080/myapp/
URL addressUpdate existing web application using overwrite trick.
http://localhost:8080/myapp/
URL addressOr update existing web application using delete-copy trick.
http://localhost:8080/myapp/
URL addressReason for a temporary war.zip filename is ensure file is fully copied to a destination folder before Tomcat touches it. Copying large files directly to .war filename may trigger Tomcat reading halfsized file content.
Upvotes: 2