0
votes

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.

3

3 Answers

5
votes

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.

2
votes

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

0
votes

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