Permalink
Browse files

Adds CKAN cookbook and dependencies.

  • Loading branch information...
vitorbaptista committed Jan 11, 2013
1 parent ee70806 commit e19871154eef8b75feea725658bf31d30f3230d0
View
@@ -1,2 +1,3 @@
.vagrant
+.chef
*.swp
View
@@ -0,0 +1,15 @@
+[submodule "cookbooks/python"]
+ path = cookbooks/python
+ url = git://github.com/opscode-cookbooks/python.git
+[submodule "cookbooks/build-essential"]
+ path = cookbooks/build-essential
+ url = git://github.com/opscode-cookbooks/build-essential.git
+[submodule "cookbooks/apt"]
+ path = cookbooks/apt
+ url = git://github.com/opscode-cookbooks/apt.git
+[submodule "cookbooks/git"]
+ path = cookbooks/git
+ url = git://github.com/opscode-cookbooks/git.git
+[submodule "cookbooks/postgresql"]
+ path = cookbooks/postgresql
+ url = git://github.com/phlipper/chef-postgresql.git
View
@@ -9,8 +9,25 @@ Vagrant::Config.run do |config|
config.vm.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
config.vm.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/openspending", "1"]
config.vm.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/openspendingjs", "1"]
+ # Check https://github.com/mitchellh/vagrant/issues/516
+ config.vm.customize(["modifyvm", :id, "--nictype1", "Am79C973"])
config.vm.customize do |vm|
vm.memory_size = 1024
end
+
+ config.vm.forward_port 8983, 8983
+ config.vm.forward_port 5000, 5000
+
+ config.vm.provision :chef_solo do |chef|
+ chef.json = {
+ "user" => "vagrant",
+ "postgresql" => {
+ "ssl" => false
+ }
+ }
+ chef.add_recipe("apt")
+ chef.add_recipe("ckan")
+ end
+
end
Submodule apt added at 2194db
Submodule build-essential added at 0c6365
@@ -0,0 +1,4 @@
+NO_START=0
+JETTY_HOST=127.0.0.1
+JETTY_PORT=8983
+JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64/
@@ -0,0 +1,33 @@
+{
+ "name": "ckan",
+ "description": "Installs and configures CKAN for development.",
+ "long_description": "",
+ "maintainer": "Vitor Baptista",
+ "maintainer_email": "vitor@vitorbaptista.com",
+ "license": "Apache v2.0",
+ "platforms": {
+ },
+ "dependencies": {
+ "git": ">= 0.0.0",
+ "python": ">= 0.0.0",
+ "postgresql": ">= 0.0.0",
+ },
+ "recommendations": {
+ },
+ "suggestions": {
+ },
+ "conflicting": {
+ },
+ "providing": {
+ },
+ "replacing": {
+ },
+ "attributes": {
+ },
+ "groupings": {
+ },
+ "recipes": {
+ },
+ "version": "0.1.0"
+}
+
@@ -0,0 +1,9 @@
+name "ckan"
+description "Installs and configures CKAN for development."
+version "0.1.0"
+maintainer "Vitor Baptista"
+maintainer_email "vitor@vitorbaptista.com"
+license "Apache v2.0"
+depends "git"
+depends "python"
+depends "postgresql"
@@ -0,0 +1,91 @@
+include_recipe "git"
+include_recipe "python"
+include_recipe "postgresql::server"
+include_recipe "postgresql::libpq"
+
+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"
+
+# Install Python
+python_virtualenv ENV['VIRTUAL_ENV'] do
+ interpreter "python2.7"
+ owner USER
+ group USER
+ options "--no-site-packages"
+ action :create
+end
+
+# Install CKAN Package
+python_pip "git+https://github.com/okfn/ckan.git#egg=ckan" do
+ user USER
+ group USER
+ virtualenv ENV['VIRTUAL_ENV']
+ options "-e"
+ action :install
+end
+
+# Install CKAN's requirements
+python_pip "#{SOURCE_DIR}/pip-requirements.txt" do
+ user USER
+ group USER
+ virtualenv ENV['VIRTUAL_ENV']
+ options "-r"
+ action :install
+end
+
+# Create Database
+pg_user "ckanuser" do
+ privileges :superuser => true, :createdb => true, :login => true
+ password "pass"
+end
+
+pg_database "ckantest" do
+ owner "ckanuser"
+ encoding "utf8"
+end
+
+# Install and configure Solr
+package "openjdk-6-jdk"
+package "solr-jetty"
+cookbook_file "/etc/default/jetty"
+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"
+ action :run
+end
+service "jetty" do
+ supports :status => true, :restart => true, :reload => true
+ action [:enable, :start]
+end
+
+# Create configuration file
+execute "make paster's config file and setup solr_url and ckan.site_id" do
+ user USER
+ cwd SOURCE_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"
+end
+
+# Generate database
+execute "create database tables" do
+ user USER
+ cwd SOURCE_DIR
+ command "paster --plugin=ckan db init"
+end
+
+# Run tests
+python_pip "#{SOURCE_DIR}/pip-requirements-test.txt" do
+ user USER
+ group USER
+ virtualenv ENV['VIRTUAL_ENV']
+ options "-r"
+ action :install
+end
+
+execute "running tests with SQLite" do
+ user USER
+ cwd SOURCE_DIR
+ command "nosetests --ckan ckan"
+end
Submodule git added at d0eeb6
Submodule postgresql added at 5719d7
Submodule python added at 34cb92

0 comments on commit e198711

Please sign in to comment.