Question

I'm using the chef-ckan cookbooks from Vitor Baptista to setup a CKAN installation for Vagrant.

Everything is working fine, but I can't find the way to make CKAN load the source code from my host OS (in this case the cloned directory in OSX).

Currently our CKAN code (the repo code) in the host OS is shared with Vagrant as /vagrant. The problem is that the CKAN virtual environment is reading the source from ~/pyenv/src/ckan which doesn't include our commits.

How could we link both directories?

UPDATE 1:
Looks like vm.shared_folder won't do the trick, since it maps host folders to vm folders. I'm also looking at the cookbooks/ckan/recipes and found a SOURCE_DIR constant, but doesn't solve the issue.

USER = node[:user]
HOME = "/home/#{USER}"
ENV['VIRTUAL_ENV'] = "#{HOME}/pyenv"
ENV['PATH'] = "#{ENV['VIRTUAL_ENV']}/bin:#{ENV['PATH']}"
SOURCE_DIR = "#{ENV['VIRTUAL_ENV']}/src/ckan"

UPDATE 2:
Just found out this line in the recipe https://github.com/vitorbaptista/chef-ckan/blob/master/cookbooks/ckan/recipes/default.rb#L29 which perhaps we could link to the vm.shared_folder so the CKAN installation reads the source from our host OS.

Still not working. Just wondering if vagrant reload is not enough, and I should do a vagrant destroy; vagrant up

Was it helpful?

Solution 2

I finally got it, by sharing my CKAN fork directoy with the VM (in this case the parent directoy since the Vagrantfile is inside the chef-ckan submodule):

config.vm.share_folder "ckan", "/vagrant", ".."

Reference: https://github.com/wilhelmbot/chef-ckan/commit/3cacc6969e8e257862cbc13f32a4d9f271850f27

and changing the CKAN recipes to use the shared folder as the SOURCE DIRECTORY (as Vitor pointed out) https://github.com/wilhelmbot/chef-ckan/commit/cc338f6946efc3968c3b8bded6df00010e9e4732

NOTE:
I couldn't make the git reference attribute to work, that's why I didn't use the full solution proposed by Vitor.

I was getting STDOUT: STDERR: fatal: Could not parse object 'e0648dbf...'

OTHER TIPS

(I've just added this to chef-ckan's repository, so it's easier to simply update it. Here I'm just explaining the fix.)

The problem is that I've used pip install --editable to both clone CKAN's repository and install it. To do what you want, you'll need to break these two steps apart.

Before the # Install CKAN Package step, add:

git SOURCE_DIR do
  user USER
  group USER
  repository "git://github.com/okfn/ckan.git"
  reference "master"
  enable_submodules true
end

And then edit the installation to be:

python_pip SOURCE_DIR do
  ...
end

Then you can change SOURCE_DIR for whatever you like (i.e. /vagrant/ckan), and it should work. It just can't be a subdirectory whose parent wasn't created yet. For example, if SOURCE_DIR is "/vagrant/src/ckan", "/vagrant/src" have to exist already.

By default, the git chef's recipe updates the cloned repository whenever it's run. If you want to change that, check its documentation at http://docs.opscode.com/resource_git.html.

Cheers!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top