2

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?

Vladimir Hraban
  • 3,543
  • 4
  • 26
  • 46
  • You may have searched the doc about the package resource [here](http://docs.chef.io/chef/resources.html#package) 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 wou'll want to update the version. – Tensibai Dec 29 '14 at 12:46
  • @Tensibai Thanks, that's what I was looking for. Can you submit this as an answer so I can accept it? – Vladimir Hraban Dec 29 '14 at 14:38

1 Answers1

2

See the documenation 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 wou'll want to update the version.

exemple:

in atrtibute file:

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

in recipe file:

package "httpd" do
  version node['httpd']['version']
end
Tensibai
  • 15,557
  • 1
  • 37
  • 57