问题
Using vagrant-berkshelf with the Maven and Tomcat cookbooks, I can specify a major version to install.
Example: Maven - 2 or 3 Tomcat - 5 or 6
If I want to specify an exact version of a library (Maven 3.2.1), should I just use the Ark Cookbook to install the desired version?
Having limited DevOps experience, I'm used to making use of yum
or apt-get
to manage my libraries without specifying a particular version.
回答1:
The Maven cookbook already uses ark. So you could just override the following node attributes:
node['maven']['version'] = 3
node['maven']['3']['version'] = '3.2.1'
node['maven']['3']['url'] = ???
node['maven']['3']['checksum'] = ???
The tomcat cookbook on the other hand does a package install, so you'd need to use ark or build a Deb/RPM package.
The only downside to using ark for tomcat is that you won't have service scripts to manage tomcat's stop/start/status. Some extra work would be needed.
Update
The following is a vagrant project that installs Maven 3.2.1
├── Berksfile
└── Vagrantfile
Vagrantfile
Vagrant.require_plugin "vagrant-omnibus"
Vagrant.require_plugin "vagrant-berkshelf"
Vagrant.require_plugin "vagrant-chef-zero"
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Box config
config.vm.box = "saucy64"
config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/saucy/current/saucy-server-cloudimg-amd64-vagrant-disk1.box"
# Virtualbox config
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", 4096]
end
# Networking config
config.vm.network "private_network", ip: "10.0.0.10"
# Plugin config
config.omnibus.chef_version = :latest
config.chef_zero.enabled = true
config.berkshelf.enabled = true
# Chef config
config.vm.provision :chef_client do |chef|
chef.add_recipe "apt"
chef.add_recipe "maven"
chef.json = {
'maven' => {
'version' => 3,
'3' => {
'version' => '3.2.1',
'url' => 'http://www.eu.apache.org/dist/maven/maven-3/3.2.1/binaries/apache-maven-3.2.1-bin.tar.gz',
'checksum' => 'cdee2fd50b2b4e34e2d67d01ab2018b051542ee759c07354dd7aed6f4f71675c'
}
}
}
end
end
Berksfile
site :opscode
cookbook 'apt'
cookbook 'maven'
来源:https://stackoverflow.com/questions/22578830/installing-a-particular-library-version