Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Parametize CKAN's repository.

This was a problem faced by willhelmbot at
http://stackoverflow.com/questions/16242798/how-to-link-a-ckan-installation-in-vagrant-to-a-cloned-repo-in-the-host-os/16243862#16243862

He wanted to clone his own repository, instead of the official CKAN's, and also
wanted to clone it inside /vagrant/ckan, so he could do changes using the host
OS.

This solves both.
  • Loading branch information...
commit 38b788b74db6daf2c3ea8a2ea0a40178e2e5acf6 1 parent 63a0340
@vitorbaptista authored
View
11 cookbooks/ckan/recipes/ckanext.rb
@@ -2,7 +2,8 @@
HOME = "/home/#{USER}"
ENV['VIRTUAL_ENV'] = "#{HOME}/pyenv"
ENV['PATH'] = "#{ENV['VIRTUAL_ENV']}/bin:#{ENV['PATH']}"
-SOURCE_DIR = "#{ENV['VIRTUAL_ENV']}/src/ckan"
+SOURCE_DIR = "#{ENV['VIRTUAL_ENV']}/src"
+CKAN_DIR = "#{SOURCE_DIR}/ckan"
# Create Database
pg_user "ckanuser" do
@@ -23,24 +24,24 @@
# Configure database variables
execute "Set up datastore database's urls" do
user USER
- cwd SOURCE_DIR
+ cwd CKAN_DIR
command "sed -i -e 's/.*datastore.write_url.*/ckan.datastore.write_url=postgresql:\\/\\/ckanuser:pass@localhost\\/datastore/;s/.*datastore.read_url.*/ckan.datastore.read_url=postgresql:\\/\\/readonlyuser:pass@localhost\\/datastore/' development.ini"
end
# Set permissions
execute "don't ask for postgres password when setting database's permissions" do
user USER
- cwd "#{SOURCE_DIR}/ckanext/datastore/bin"
+ cwd "#{CKAN_DIR}/ckanext/datastore/bin"
command "sed -i -e 's/-W//g' datastore_setup.py"
end
execute "set permissions" do
- cwd SOURCE_DIR
+ cwd CKAN_DIR
command "paster datastore set-permissions postgres"
end
execute "run other tests" do
user USER
- cwd SOURCE_DIR
+ cwd CKAN_DIR
command "nosetests --ckan --with-pylons=test-core.ini --nologcapture --cover-package=ckanext.datastore ckanext/datastore/tests -x"
end
View
46 cookbooks/ckan/recipes/default.rb
@@ -5,10 +5,12 @@
include_recipe "java"
USER = node[:user]
+REPOSITORY = node[:repository]
HOME = "/home/#{USER}"
ENV['VIRTUAL_ENV'] = "#{HOME}/pyenv"
ENV['PATH'] = "#{ENV['VIRTUAL_ENV']}/bin:#{ENV['PATH']}"
-SOURCE_DIR = "#{ENV['VIRTUAL_ENV']}/src/ckan"
+SOURCE_DIR = "#{ENV['VIRTUAL_ENV']}/src"
+CKAN_DIR = "#{SOURCE_DIR}/ckan"
# Create user
user USER do
@@ -25,17 +27,32 @@
action :create
end
+# Create source dir
+directory SOURCE_DIR do
+ owner USER
+ group USER
+end
+
+# Clone CKAN
+git CKAN_DIR do
+ user USER
+ group USER
+ repository REPOSITORY
+ reference "master"
+ enable_submodules true
+end
+
# Install CKAN Package
-python_pip "git+https://github.com/okfn/ckan.git#egg=ckan" do
+python_pip CKAN_DIR do
user USER
group USER
virtualenv ENV['VIRTUAL_ENV']
- options "-e"
+ options "--exists-action=i -e"
action :install
end
# Install CKAN's requirements
-python_pip "#{SOURCE_DIR}/pip-requirements.txt" do
+python_pip "#{CKAN_DIR}/pip-requirements.txt" do
user USER
group USER
virtualenv ENV['VIRTUAL_ENV']
@@ -49,11 +66,18 @@
password "pass"
end
-pg_database "ckantest" do
+pg_database "ckan_dev" do
owner "ckanuser"
encoding "utf8"
end
+# Configure database variables
+execute "Set up database's urls" do
+ user USER
+ cwd CKAN_DIR
+ command "sed -i -e 's/.*sqlalchemy.url.*/sqlalchemy.url=postgresql:\\/\\/ckanuser:pass@localhost\\/ckan_dev/;' development.ini"
+end
+
# Install and configure Solr
package "solr-jetty"
template "/etc/default/jetty" do
@@ -62,7 +86,7 @@
})
end
execute "setup solr's schema" do
- command "sudo ln -f -s #{SOURCE_DIR}/ckan/config/solr/schema-2.0.xml /etc/solr/conf/schema.xml"
+ command "sudo ln -f -s #{CKAN_DIR}/ckan/config/solr/schema-2.0.xml /etc/solr/conf/schema.xml"
action :run
end
service "jetty" do
@@ -73,20 +97,20 @@
# Create configuration file
execute "make paster's config file and setup solr_url and ckan.site_id" do
user USER
- cwd SOURCE_DIR
+ cwd CKAN_DIR
command "paster make-config ckan development.ini --no-interactive && sed -i -e 's/.*solr_url.*/solr_url=http:\\/\\/127.0.0.1:8983\\/solr/;s/.*ckan\\.site_id.*/ckan.site_id=vagrant_ckan/' development.ini"
- creates "#{SOURCE_DIR}/development.ini"
+ creates "#{CKAN_DIR}/development.ini"
end
# Generate database
execute "create database tables" do
user USER
- cwd SOURCE_DIR
+ cwd CKAN_DIR
command "paster --plugin=ckan db init"
end
# Run tests
-python_pip "#{SOURCE_DIR}/pip-requirements-test.txt" do
+python_pip "#{CKAN_DIR}/pip-requirements-test.txt" do
user USER
group USER
virtualenv ENV['VIRTUAL_ENV']
@@ -96,6 +120,6 @@
execute "running tests with SQLite" do
user USER
- cwd SOURCE_DIR
+ cwd CKAN_DIR
command "nosetests --ckan ckan"
end
View
1  solo.json
@@ -5,6 +5,7 @@
"recipe[ckan::ckanext]"
],
"user": "ckan",
+ "repository": "https://github.com/okfn/ckan.git",
"postgresql": {
"version": "9.1",
"ssl": false
Please sign in to comment.
Something went wrong with that request. Please try again.