0

In the Chef legacy Apache tutorial there is no reference to any dependency on the apache2 cookbook, yet the tutorial seems to work and install Apache without it.

When learning Chef, I found this to be confusing because when I went to create my first recipe I was surprised to have to deal with downloading/uploading cookbook dependencies.

How does the tutorial work without having to download/upload the apache2 cookbook or even declaring a dependency on the apache2 cookbook? It seems like it shouldn't work at all.

Ken Liu
  • 22,503
  • 19
  • 75
  • 98

3 Answers3

5

There's no dependency on an apache2 cookbook here.

The tutorial walks the reader through creation of a apache-tutorial-1 cookbook with a default recipe. The recipe contents, from the tutorial are:

package 'apache2' do
  action :install
end

service 'apache2' do
  action [ :enable, :start ]
end

cookbook_file '/var/www/index.html' do
  source 'index.html'
  mode '0644'
end

The apache2 package gets installed and Apache HTTPD works because this recipe does that. You don't need the full bowl of the community apache2 cookbook for this. Nor do you need Berkshelf in the equation to get this done.

The tutorials are intended to teach the basics so that users can learn the fundamentals of Chef. Learning additional tools that have their own ecosystem is out of scope for that purpose. If you're looking to send an email, you wouldn't learn how to setup postfix and spamassassin and procmail and so on.

jtimberman
  • 8,228
  • 2
  • 43
  • 37
  • Ah-ha! It was unclear to me from going through the tutorial that the `package` method simply installs a package via the OS-specific package manager (in my case `apt`); I thought it was referring to the `apache2` community cookbook somehow. Thanks for clearing that up. – Ken Liu Jul 24 '14 at 23:50
  • Yup, the cookbook is named after the thing it's managing, in this case 'apache2' as that seems intuitive - for certain quantities of intuitive (not always true, but at least here it applies anyway :)) – jtimberman Jul 25 '14 at 20:21
2

The tutorial implements an Apache cookbook as a simple example of how to write a cookbook. Think of it as a "hello world".

Using community cookbooks is not in scope for the language tutorial. Cookbooks on the Supermarket are not "Core Chef" are not required to use Chef.

To make some comparisons, it is possible to use Java without using Maven. It is possible to use Ruby without relying on anything found on Rubygems. It is possible to use Python without consuming modules from PyPI.

-s

someara
  • 21
  • 1
0

If I understand your question right, the missing piece for that you are searching for is Berkshelf.

StephenKing
  • 36,187
  • 11
  • 83
  • 112