chef-infrachef-recipechef-solo

Chef - install a specific version of apache


I run CentOS 6.5 on my vagrant VM and I need to install a specific version of Apache (2.2.15) to make it a similar configuration to live environment.

I currently have

package("httpd")

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

And it obviously installs the most recent version yum knows about. This is indeed 2.2.15 but I do not want to rely solely on that as yum check-update may change the newest release package.

I am going to do the same thing with MySQL & PHP.

How can it be achieved?


Solution

  • See the documentation for the package resource here there's an attribute named version for the package resource which is what you're looking for.

    Side note: prefer attributes referenced in the resource to stick the version instead of hardcoding them in the recipe, it is less error prone when you'll want to update the version.

    exemple:

    in the attribute file:

    default['httpd']['version'] = "2.2.15"
    

    in recipe file:

    package "httpd" do
      version node['httpd']['version']
    end