Pergunta

I'm having an issue where my chef.json attributes in my Vagrantfile seem to be getting ignored/overwritten.

Environment: Mac OS X 10.8 host, Ubuntu 12.04 guest virtualized in VirtualBox 4.18. Using Berkshelf for cookbook dependencies and the Opscode cookbooks for all of the recipes.

The box is spinning up fine, but I'm trying to configure more like it would look if I downloaded Jetty and un-tarred the archive, rather than a bunch of symlinks from /usr/share/jetty to all over the filesystem the way it seems to be defaulting to.

Here's the chef portion of my Vagrantfile:

config.vm.provision :chef_solo do |chef|

  chef.json = { :java => {
                :install_flavor => "oracle",
                :jdk_version => '7',
                :oracle => {
                  :accept_oracle_license_terms => true 
                }
              },
              :jetty => {
                :port => '8080',
                :home => '/opt/jetty',
                :config_dir => '/opt/jetty/conf',
                :log_dir => '/opt/jetty/log',
                :context_dir => '/opt/jetty/context',
                :webapp_dir => '/opt/jetty/webapp'
              }
            }

 chef.add_recipe "apt"
 chef.add_recipe "mongodb::default"
 chef.add_recipe "java"
 chef.add_recipe "jetty"
end

Chef seems to be reading the chef.json because I can change Jetty's port in the Vagrantfile.

I've tried to change these attributes in attributes/default.rb of the Jetty cookbook, but that didn't help either.

What am I missing?

Foi útil?

Solução

If you take a look at the below block in jetty/recipes/default.rb

jetty_pkgs = value_for_platform(
  ["debian","ubuntu"] => {
    "default" => ["jetty","libjetty-extra"]
  },
  ["centos","redhat","fedora"] => {
    "default" => ["jetty6","jetty6-jsp-2.1","jetty6-management"]
  },
  "default" => ["jetty"]
)
jetty_pkgs.each do |pkg|
  package pkg do
    action :install
  end
end

For Debian/Ubuntu, the default recipe uses DEB packages from official repository instead of what you want (download binary from official website, untar it into your preferred location).

Because DEB packages have their own specifications (run dpkg -L jetty to see their files/directories structure), I reckon that's why your attribute overrides in chef.json did not work.

You can enable debugging output to see more information when you run provision again

VAGRANT_LOG=debug vagrant up

NOTE: It's probably better off writing your own cookbook to download the binary and untar set permissions and do other stuff if you want Jetty to be installed the way you like;-)

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top