Search code examples
tomcatchef-infradevopscookbook

How to run the tomcat cookbook downloaded from chef supermarket?


I'm quite a newbie on Chef and I'm trying to do the first steps, so sorry for the simply question and for mistakes..

I've followed the official tutorial so I've concepts quite clear and I've seen how to build a cookbook, how to check using kitchen converge and how to upload it on Chef Server.

Now I'd like to build a simple cookbook that use the tomcat cookbook downloaded from chef supermarket.

I havent'd found a tutorial / examples for this so, you know something that could be useful please give me the link.

What I've tried to do:

  1. my cookbook name is test and I've generated it using chef generate cookbook test
  2. I've modified the kitchen.yml file for my target platform that is CentOS 7 so - name: centos-7
  3. I've created my kitchen instance with the command kitchen create and then the command kitchen converge
  4. tested if my SSH connection is working with the command kitchen exec .c whoami
  5. all work fine untill now
  6. I've seen that on Chef supermarket there is a cookbook named tomcat (ref. https://supermarket.chef.io/cookbooks/tomcat)
  7. I've modified Berksfile in this way
source 'https://supermarket.chef.io'

metadata

cookbook 'tomcat'

Then I've modified metadata.rb adding depends 'tomcat', '~> 3.0.0'

Now, how have I to modify my default.rb recipe (or other files ...), to obtain a working cookbook?


Solution

  • It is a good practice to run berks install after change to Berksfile, it will update Berksfile.lock. Then, kitchen converge will transfer all files to the VM. In default.rb of your cookbook you should use tomcat's cookbook resources as described in the README.md. For example:

    tomcat_install 'helloworld' do
      version '8.0.36'
    end