Installing Apache Tomcat using Chef

Agenda:

To install Apache Tomcat 8 on the node using Chef

Requirements:

  • Chef Server
  • Chef Work Station
  • Node to install and run the Tomcat
  • Tomcat cookbook and its dependencies (if any)
  • Tomcat and its dependencies can be downloaded from Chef Supermarket

Dependencies:

  1. java >= 0.0.0
  • homebrew >= 0.0.0
  • windows >= 0.0.0
  • apt >= 0.0.0
  • ohai >= 4.0.0

How to:

  • After downloading Tomcat and its dependency Cookbooks from the Chef Supermarket into your local machine, from your Chef DK browse into the chef-repo folder
  • Create a new cookbook tomcat8 using the following command “knife cookbook create tomcat8”
  • A cookbook will be created in the /cookbooks folder.
  • Copy the cookbooks which you have already downloaded (tomcat, java, apt, homebrew, windows and ohai) into /cookbooks folder.
  • From your Chef DK, push the cookbook to the Chef Server using the following command “knife cookbook upload tomcat8” and you will encounter will an error that dependencies are missing.
  • So, upload the dependencies first and then upload the tomcat8 cookbook.
  • To do this, use the below commands to upload the cookbooks one by one in the below format
  1. knife cookbook upload homebrew
  2. knife cookbook upload ohai
  3. knife cookbook upload windows
  4. knife cookbook upload apt
  5. knife cookbook upload java
  6. Then finally, knife cookbook upload tomcat
  • All the cookbooks can be uploaded in one go using the following command “knife cookbook upload -a”
  • After all the cookbooks are uploaded into the Chef server, check the cookbooks in the Chef GUI.
  • Now add the tomcat cookbook to the node’s run list using the following command “knife node run_list add node_name “recipe[tomcat8]””
  • Even we can add the run list from the Chef GUI by going to the node’s tab, direct to the Edit Run List on the left-hand side.
  • Drag in the tomcat recipe in the Available Recipe to Current Run List.
  • After adding the run list to a following node, connect to the node using Putty.
  • After getting logged in, use the command to install and run the tomcat8 cookbook using “sudo chef-client”
  • And that’s it you can see the tomcat8 is being installed on the assigned node.
  • To check tomcat is up and running use the following code “service tomcat8 status” from your node machine.
  • To access from the web browser, use your node IP address follow by 8080 (port) which looks like http://xxx.xxx.xxx.xxx:8080/
  • An Apache Tomcat home page is displayed if Tomcat is successfully installed.

Conclusion:

we have successfully tomcat using chef

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s