-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdatahub.yml
195 lines (148 loc) · 5.43 KB
/
datahub.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
---
- hosts: datahub
sudo: yes
pre_tasks:
- name: Update APT cache if stale
apt: update_cache=yes cache_valid_time=3600
tasks:
# Base
- name: Install system packages
apt: pkg={{ item }}
with_items:
- curl
- gcc
- git
- htop
- libxslt1-dev
- python-dev
- python-pip
- python-software-properties
- python-virtualenv
- vim
- wget
# CKAN
- name: Install CKAN prerequisites
apt: pkg={{ item }}
with_items:
- nginx
- apache2
- libapache2-mod-wsgi
- libpq5
- name: Download CKAN
get_url: url=http://packaging.ckan.org/{{ ckan_package }}
dest=~/{{ ckan_package }}
register: ckan_download
# When Ansible 1.3 is released, add:
# sha256sum: {{ ckan_package_sha56sum }}
- name: Install CKAN
shell: dpkg -i ~/{{ ckan_package }}
when: ckan_download.changed
- name: Configure CKAN
template: src=production.ini.j2 dest=/etc/ckan/default/production.ini
# Solr
- name: Install Solr prerequisites
apt: pkg={{ item }}
with_items:
- openjdk-6-jdk
- name: Install Solr PPA
apt_repository: repo='ppa:lucene-ubuntu/dev'
register: solr_repo
- name: Update APT cache
apt: update_cache=yes
when: solr_repo.changed
- name: Install Solr
apt: pkg=solr-jetty
- name: Configure Jetty service
template: src=default-jetty.j2 dest=/etc/default/jetty
notify:
- Restart Jetty
- name: Link Solr schema configuration
template: src=solr-schema.xml dest=/etc/solr/conf/schema.xml
notify:
- Restart Jetty
# PostgreSQL and PostGIS
- name: Install PostgreSQL
apt: pkg={{ item }}
with_items:
- postgis
- postgresql-9.1
- postgresql-9.1-postgis
- python-psycopg2
- name: Create CKAN PostgreSQL user
postgresql_user: user=ckan_default password={{ db_password }}
sudo_user: postgres
- name: Create CKAN PostgreSQL database
postgresql_db: db=ckan_default owner=ckan_default
template='template0' encoding='UTF-8'
sudo_user: postgres
- name: Check PostGIS in CKAN database
shell: psql -d ckan_default -c "SELECT postgis_full_version()" 2>/dev/null
sudo_user: postgres
ignore_errors: yes
register: postgis_check
- name: Install PostGIS into CKAN database
command: psql -d ckan_default -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql
sudo_user: postgres
when: postgis_check|failed
- name: Install spatial references into CKAN database
command: psql -d ckan_default -f /usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql
sudo_user: postgres
when: postgis_check|failed
- name: Set owner of PostGIS and spatial reference tables
command: psql -d ckan_default -c 'ALTER TABLE spatial_ref_sys OWNER TO ckan_default; ALTER TABLE geometry_columns OWNER TO ckan_default;'
sudo_user: postgres
when: postgis_check|failed
- name: Check CKAN database
command: ckan db version
ignore_errors: yes
register: db_check
- name: Initialize CKAN database
command: ckan db init
when: db_check|failed
- name: Upgrade CKAN database
command: ckan db upgrade
when: ckan_download.changed
# CKAN Geospatial extensions
- name: Download updated version of liblzma5
get_url: url={{ liblzma5_package_url }} dest=/tmp/liblzma5.deb
register: liblzma5_download
- name: Install updated version of liblzma5
command: dpkg -i /tmp/liblzma5.deb
when: liblzma5_download.changed
- name: Download updated version of libxml2
get_url: url={{ libxml2_package_url }} dest=/tmp/libxml2.deb
register: libxml2_download
- name: Install updated version of libxml2
command: dpkg -i /tmp/libxml2.deb
when: libxml2_download.changed
- name: Download updated version of python-libxml2
get_url: url={{ python_libxml2_package_url }} dest=/tmp/python-libxml2.deb
register: python_libxml2_download
- name: Install updated version of python-libxml2
command: dpkg -i /tmp/python-libxml2.deb
when: python_libxml2_download.changed
- name: Install CKAN Geospatial extensions Python package
pip: name='git+https://github.com/okfn/ckanext-spatial.git@stable#egg=ckanext-spatial'
- name: Download CKAN Geospatial extensions requirements.txt file
get_url: url=https://raw.github.com/okfn/ckanext-spatial/stable/pip-requirements.txt
dest=/tmp/ckanext-spacial-requirements.txt force=yes
- name: Install CKAN Geospatial extensions Python dependencies
pip: requirements=/tmp/ckanext-spacial-requirements.txt
- name: Install CKAN Geospatial extensions system dependencies
apt: pkg={{ item }}
with_items:
- libgeos-c1
- name: Create CKAN Geospatial extensions database tables
command: /usr/lib/ckan/default/bin/paster --plugin=ckanext-spatial spatial initdb --config=/etc/ckan/default/production.ini
when: db_check|failed
handlers:
- name: Restart Jetty
service: name=jetty state=restarted
vars:
ckan_package: python-ckan-2.0_amd64.deb
ckan_package_sha256sum: 157fb8bedfb76d1404b1abddc439127eec248e4318a16b894d15de6b77d419eb
liblzma5_package_url: http://launchpadlibrarian.net/127500119/liblzma5_5.1.1alpha%2B20120614-2ubuntu1_amd64.deb
libxml2_package_url: https://launchpadlibrarian.net/145108632/libxml2_2.9.0%2Bdfsg1-4ubuntu4.3_amd64.deb
python_libxml2_package_url: https://launchpadlibrarian.net/145108639/python-libxml2_2.9.0%2Bdfsg1-4ubuntu4.3_amd64.deb
vars_files:
- secrets.yml