How to link a CKAN installation in Vagrant to a cloned repo in the host OS? - pip

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

(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!

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...'

Related

Multiple Homestead Boxes

I'm trying to install multiple of the same homestead box. Each one for a different project, totally isolated from each other. None of them will be run concurrently, only one at a time.
But when I try to run vagrant up, it tells me that a box with the name 'homestead-7' already exists. How can I rename it?
I don't see the name anywhere in the vagrantfile in the project directory, nor any 'boxes' folder in either the project .vagrant directory or my home .vagrant directory. vagrant global-status tells me that there is 1 homestead-7 box already for the project that is already in progress.
You need to add "name" property under your "Homestead.yaml" file, for example:
name: my-new-homestead
and make sure that your authorize, keys and folders are pointing to the correct path.
To use Homestead in a per project basis, you need to add it as a dependency in each one of your projects:
composer require laravel/homestead --dev
Use php vendor/bin/homestead make to generate the Vagrantfile and Homestead.yaml files. Then you can simply run vagrant up from your project.
See more on the Laravel documentation.

how to configure cygwin Local Package Directory

I have to change my cygwin Local Package Directory, which happen to be earlier as C:\Users\username\Downloads.
Folders like http%3a%2f%2fcygwin.mirror.constant.com%2f are all in place in my new directory for Local Package Directory.
How to do that? (I cannot find, where cygwin stores the config.)
Running setup from new location tries to install all over again instead from continue using earlier packages from the internet.
The information is on /etc/setup/setup.rc
$ head setup.rc
last-cache
e:\downloads\cygwin_cache
last-mirror
http://mirrors.kernel.org/sourceware/cygwin/
net-method
Direct
last-action
Download,Install
mirrors-lst
....
Please note that setup just propose the settings based on last run but you can always change typing new values.

Existing GIT repo with vagrant file

I just started using Vagrant. Now, One of my clients shared a GIT repo with the following files & directories :
Vagrantfile (file)
Vagrant (directory)
Now, I don't understand what will be my next step ? Every resource in the internet assumes that I am creating a new box from scratch (vagrant init hashicorp/precise64). But, here I need to match the box environment that is shared with me.
Thanks.
As stated in the previous answers - download the repository, and enter (cd via command line) the directory.
Once in there - you should just be able to run vagrant up to initiate the download and configuration of the vagrant box. Your client will (in theory) have set up the Vagrantfile to configure the machine appropriately.
Note: It might be worth checking to see if they have specified a hostname for the box [i.e mynewproject.dev] (found in Vagrantfile or sometimes, in a .yaml configuration file (i.e site.yaml).
If they have - it would be worth updating your hosts file to make sure you can use the host name locally.
The Vagrantfile will described everything about the VM you will build, so it knows about the vagrant box to use, you will have something like
Vagrant.configure("2") do
....
config.box = "hashicorp/precise64"
...
end
If the box is available freely on Atlas (such as hashicorp/precise64) vagrant will download the box and spin a new VM. If the box is not freely available, you will need to install yourself with vagrant box add

Error when running vagrant: "The host path of the shared folder is missing"

I have downloaded a Vagrantfile, but when i run vagrant up in terminal the following message appears:
Bringing machine 'default' up with 'virtualbox' provider... There are
errors in the configuration of this machine. Please fix the following
errors and try again:
vm:
* The host path of the shared folder is missing: ~/Sync
OBS.: Using Ubuntu 14.10
I created a folder named Sync in my home.
According to Vagrant docs host path must be either absolute (i.e. /home/user/Sync) or relative to project root (place where your Vagrantfile is).
Relative to project root means if your Vagrantfile resides in /home/user/MyProject then setting up path as "Sync" will create share from /home/user/MyProject/Sync.
Ref: http://docs.vagrantup.com/v2/synced-folders/basic_usage.html
I assumed you are in linux or mac. Type in "pwd" and enter in the terminal where Homestead.yml is.
Mine is "/home/idhamhafidz/Code/opp190-ama"
Then go to your Homestead.yml and edit the folders section like in the image below:
Then quit edit Homesteady.yml and re-run vagrant up again.
In my case it was a space at the end of the path in config.yaml:
source: '/Users/h/Packt/Code '
I've deleted this space and it's working now.
If you are using Vagrant and Windows Subsystem for Linux then you can solve the issue creating a symlink
ln -s /mnt/c/Users/user/project ~/project
/mnt/c/Users/user/project should match the Vagrant project in your Windows machine.
~/project should match the path that is missing.
Note, that you may need to create any intermediary directories.
I know this is an old question, but for anyone just encountering this issue and having a hard time finding a conclusion the answer by #megawebmaster would be the correct approach in giving the relative path to the folder: "/home/(your-pc-username)/Sync/".
Also with a Vagrantfile being ruby-based I personally use ruby's ENV object:
#{ENV["HOME"]}/Sync should resolve the issue.
I came across the same problem and
mkdir ~/Sync help me solve it.

Cannot access Vagrant shared folders

I just trying to add Vagrant to my workflow and I have following probably noob problem. I pull standard hashicorp standard 14.04 image, vagrant up it, SSH to it install my python requirements on it and then then try to execute build commands against code in Vagrant shared folder and run in to problems. Basic errors I get say those locations don't exist or cannot be found.
First action I, go ls /vagrant and can see my shared folders. I cannot cd to them from Vagrant machine I have tried to halt the machine.
Vagrantfile shared folder code.
{"virtualbox":{"/vagrant":{"guestpath":"/vagrant","hostpath":"/Users/Kimmo/Documents/Mist.io","disabled":false}}}
I am using Virtualbox as provider newest version.
My dev machine is OSX 10.9.5
There are not access limitations on the folder itself.
Thanks for you help in advance :)
Does /vagrant exists inside the VM just after you start it ?
If no you can add this parameter : "create":true. According to the doc, for the create: true paramater : If true, the host path will be created if it does not exist. Defaults to false.
If the folder /vagrant exists but you can cd or ls it, you can add parameters wich will define the right/owner of this folder:
owner: (string) the user who should be the owner of this synced folder. By default this will be the SSH user. Some synced folder types don't support modifying the owner.
group: (string) the group that will own the synced folder. By default this will be the SSH user. Some synced folder types don't support modifying the group.
Also for the hostpath parameter you have to give him a folder path, not a file path. In your conf I can see: "hostpath":"/Users/Kimmo/Documents/Mist.io". If Mist.io is a file and you want to access this file inside your VM, just give the path to the folder containing this file, /Users/Kimmo/Documents in your case.

Resources