This is an ansible playbook for building and minimally deploying CKAN on Ubuntu 14.04 host. This playbook tries as much as possible to follow the recommended way of installing CKAN from source while adhering to Ansible best practices. After successfully running this playbook, there are some additional tasks which must be run manually such as initializing databases, copying site theme, content e.t.c.
By default, this playbook assumes that you're installing CKAN & its dependencies(solr, postgresql, nginx & apache) on one host. And you'll be using apache web server primarily for python WSGI support via nginx web server on the front(reverse proxy) i.e. port 80 as recommended by CKAN docs.
This playbook is broken down the following several parts/roles, each doing a minimal & specific tasks:
apacherole: Installs & configures apache2. Apache provides modwsgi which allows us to run python applications with WSGI interface. This role also configures apache2 to listen & serve requests on port8080since we'll have nginx on the front( port80).nginxrole: Installs & configures nginx web server. Additional configuration parameters for proxying, X-* security headers, gzip compression, caching, e.t.c. are also deployed on the remote server.postgresqlrole: This role installs & configures postgresql-9.3 server. This role doesn't create/manage postgresql users & or databases, that is done in the ckan role.solrrole: Installs & configuressolr-5.2.x. By default, this role creates one solr core—ckan_default—used by CKAN. Though CKAN doesn't insist/recommend using a specific version of solr, I decided to usesolr 5.2.1and it works fine on test environments.ckanrole: This role builds & installs CKAN from sources using pip. It creates a ckan user who owns all CKAN related files & directories, creates postgresql user & database used by CKAN, configures apache2 vhost for WSGI support & finally creates nginx vhost for proxy passing requests to apache2 WSGI processes.
NOTE
apache,nginx&ckanroles can all be grouped in one group—ckan—and are usually deployed on one host in production & test environments whereaspostgresql&solrroles are in separate groups—db & solr respectively—and are usually deployed on separate hosts too.
-
clone this repo:
$ git clone https://github.com/oguya/ansible-ckan.git $ cd ansible-ckan -
Add your
db,solrandckanhost(s) in the inventoryhostsfile, for example:ckan01host belongs to theckan,dbandsolrgroups - for more info about these groups, see sample host variables files in host_vars directory:[ckan] ckan01 [db] ckan01 [solr] ckan01 -
dry run all the playbooks:
$ ansible-playbook site.yml --ask-become-pass --check -
deploy CKAN & its dependencies(solr, postgresql, nginx & apache) on
ckan01host:$ ansible-playbook site.yml --ask-become-pass -i hosts --limit=ckan01 -
install & configure solr 5.2.x on
ckan01host:$ ansible-playbook solr.yml --ask-become-pass -i hosts --limit=ckan01 -
install & configure postgresql-9.3 on
ckan01host:$ ansible-playbook db.yml --ask-become-pass -i hosts --limit=ckan01 -
deploy CKAN on
ckan01host:$ ansible-playbook ckan.yml --ask-become-pass -i hosts --limit=ckan01
I took into assumption, a few key items when running this playbook:
- You have a provisioning user account—
provisioning—with passwordless SSH access to the target host - The provisioning user has sudo privileges on the remote host
- You're installing CKAN & its dependencies(solr, postgresql, nginx & apache) on one target host - ckan01
A few roles in this playbook e.g. postgresql, solr & nginx have been borrowed from ILRI's rmg-ansible-public repo.
Pull requests and Github issues are all welcome!
Copyright (C) 2015–2016 James Oguya
The contents of this repository are free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.