forked from ckan/ckan-packaging
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackage.yml
171 lines (140 loc) · 6.18 KB
/
package.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
---
- hosts: all
vars_prompt:
- name: version
prompt: "CKAN Version (branch or tag)"
private: True
- name: iteration
prompt: "Iteration"
private: True
- name: datapusher
prompt: "Enable DataPusher? [Y/n]"
default: "y"
private: True
tasks:
- name: make sure packages are installed
apt:
update_cache: yes
force_apt_get: yes
name:
- 'git-core'
- 'python-dev'
- 'postgresql'
- 'libpq-dev'
- 'libxml2-dev'
- 'libxslt1-dev'
- 'build-essential'
- 'apache2'
- 'libapache2-mod-wsgi'
- 'rubygems-integration'
- 'ruby-dev'
- name: stop apache before installing nginx (xenial)
service: name=apache2 state=stopped
when: (ansible_distribution_version == "16.04") or (ansible_distribution_version == "18.04")
- name: make sure nginx is installed
action: apt pkg=nginx state=present update_cache=yes
- name: install fpm
action: command gem install -v 0.4.21 fpm creates=/usr/local/bin/fpm
when: ansible_distribution_version == "14.04"
- name: install fpm (xenial)
action: command gem install -v 1.11.0 fpm -- creates=/usr/local/bin/fpm
when: ansible_distribution_version == "16.04"
- name: install fpm (bionic)
action: command gem install -v 1.11.0 fpm -- creates=/usr/local/bin/fpm
when: ansible_distribution_version == "18.04"
- name: delete old directories
action: file path={{ item }} state=absent
with_items:
- /etc/ckan
- /usr/lib/ckan
- /root/.cache/pip
- name: get setupttols (I)
action: get_url url=https://bootstrap.pypa.io/ez_setup.py dest=/tmp
- name: get setupttols (II)
action: command python /tmp/ez_setup.py
- name: get pip (I)
action: get_url url=https://bootstrap.pypa.io/get-pip.py dest=/tmp
- name: get pip (II)
action: command python /tmp/get-pip.py
- name: install virtualenv
pip:
name: virtualenv
executable: /usr/local/bin/pip2
when: ansible_distribution_version != "14.04"
- name: install virtualenv
apt:
name: python-virtualenv
when: ansible_distribution_version == "14.04"
- name: pull ckan version
action: git repo=https://github.com/ckan/ckan dest=/usr/lib/ckan/default/src/ckan version={{ version }}
- name: check requirements file name
shell: "[ -f /usr/lib/ckan/default/src/ckan/pip-requirements.txt ] && echo 'pip-requirements.txt' || echo 'requirements.txt'"
register: requirements_file_name
- name: install requirements and make virtualenv for ckan
action: pip requirements=/usr/lib/ckan/default/src/ckan/{{ requirements_file_name.stdout }} virtualenv=/usr/lib/ckan/default/ virtualenv_python=python2.7
- name: install setuptools version
pip:
name:
- setuptools==36.1
virtualenv: /usr/lib/ckan/default/
virtualenv_python: python2.7
when: ansible_distribution_version == "14.04"
- name: run setup.py develop for ckan
action: command chdir=/usr/lib/ckan/default/src/ckan/ ../../bin/python setup.py develop
- name: get ckan version
command: /usr/lib/ckan/default/bin/python -c "import ckan; print ckan.__version__"
register: ckan_version
- name: pull datapusher version
action: git repo=https://github.com/ckan/datapusher dest=/usr/lib/ckan/datapusher/src/datapusher version=0.0.15
when: datapusher == 'y'
- name: make virtualenv for datapusher (trusty)
pip:
name:
- pip==20.0.2
virtualenv: /usr/lib/ckan/datapusher/
virtualenv_python: python2.7
when: datapusher == 'y' and ansible_distribution_version == "14.04"
- name: install requirements and make virtualenv for datapusher
action: pip requirements=/usr/lib/ckan/datapusher/src/datapusher/requirements.txt virtualenv=/usr/lib/ckan/datapusher/ virtualenv_python=python2.7
when: datapusher == 'y'
- name: run setup.py develop for datapusher
action: command chdir=/usr/lib/ckan/datapusher/src/datapusher/ ../../bin/python setup.py develop
when: datapusher == 'y'
- name: create directories
action: file path={{ item }} state=directory
with_items:
- /etc/ckan/default
- /var/www/build
- name: copy all common needed files
action: copy src=common/{{ item }} dest=/{{ item }}
with_items:
- etc/ckan/default/apache.wsgi
- etc/nginx/sites-available/ckan
- etc/cron.daily/remove_old_sessions
- name: copy all distribution specific files
action: copy src={{ ansible_distribution_release }}/{{ item }} dest=/{{ item }}
with_items:
- etc/apache2/sites-available/ckan_default.conf
- name: copy source who.ini to configuration folder
action: command cp /usr/lib/ckan/default/src/ckan/who.ini /etc/ckan/default/who.ini
- name: copy executables
action: copy src=common/{{ item }} dest=/{{ item }} mode=744
with_items:
- usr/bin/ckan
- name: template the after web script
action: template src=common/tmp/after_web.j2 dest=/tmp/after_web.sh mode=744
- name: build deb main
action: command chdir=/vagrant fpm
-t deb -s dir
--name python-ckan
--description='CKAN is an open-source DMS (data management system) for powering data hubs and data portals.'
--license='AGPL v3.0'
--maintainer='CKAN team <[email protected]>'
--vendor='CKAN Association'
--url='http://ckan.org'
--after-install=/tmp/after_web.sh
--iteration {{ ansible_distribution_release }}{{ iteration }}
--version {{ ckan_version.stdout }}
--depends nginx --depends apache2 --depends libapache2-mod-wsgi --depends libpq5
--config-files /etc/apache2/sites-available/ckan_default.conf --config-files /etc/nginx/sites-available/ckan --config-files /etc/ckan/default/who.ini
/usr/lib/ckan/ /etc/ckan/ /usr/bin/ckan /etc/cron.daily/remove_old_sessions /etc/apache2/sites-available/ckan_default.conf /etc/nginx/sites-available/ckan