Search code examples
chef-infrachef-recipecookbook

Chef: No available formula with the name "httpd"


I am learning chef and I got stuck here while trying to install httpd package. I have a simple recipe to install httpd package on Mac OS. I installed ChefDK.

webserver.rb

package 'httpd' 

when I run chef-apply webserver.rb, it throws errors:

    Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of brew info --json=v1 httpd ----
STDOUT: 
STDERR: Error: No available formula with the name "httpd"
---- End output of brew info --json=v1 httpd ----
Ran brew info --json=v1 httpd returned 1

Resource Declaration:
---------------------
# In webserver.rb

  1: package 'httpd'

Compiled Resource:
------------------
# Declared in webserver.rb:1:in `run_chef_recipe'

homebrew_package("httpd") do
  action [:install]
  retries 0
  retry_delay 2
  default_guard_interpreter :default
  package_name "httpd"
  declared_type :package
  cookbook_name "(chef-apply cookbook)"
  recipe_name "(chef-apply recipe)"
end

Can some one tell me what I missed here. Thanks.


Solution

  • So let's walk through each piece of what you are doing:

    chef-apply takes a single Chef recipe and runs it locally. That means everything that happens is on your Mac laptop.

    This recipe uses a package resource to install a thing called 'httpd'. Chef includes a bunch of providers for the package resource, so on Ubuntu it uses APT, on CentOS it uses YUM, and on OS X it uses Homebrew (i.e. brew install).

    Before it installs the package, Chef checks to see if it is already installed and gathers other details on the package. For Homebrew, it uses brew info for this. So you end up with the command brew info httpd, give or take the JSON output format argument to make it easier to parse. Homebrew has no package (formula) named 'httpd' so it returns an error, which Chef then raises up the chain.

    At a deeper level, Homebrew doesn't package Apache (what I presume you are trying to install) because it comes by default in OS X. Even if it did, most packaging systems call it apache2. Only RHEL/CentOS derivatives call the package httpd still.