Search code examples
dependencieschef-infracookbook

Chef tutorial doesn't need apache2 cookbook?


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.


Solution

  • 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.