Repository navigation
Expand file tree
/
Copy pathbuild.yml
More file actions
332 lines (272 loc) · 10.3 KB
/
Copy pathbuild.yml
File metadata and controls
332 lines (272 loc) · 10.3 KB
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
---
# Requires running: ansible-galaxy install rvm_io.rvm1-ruby
# To just rebuild: ansible-playbook --private-key=~/.vagrant.d/insecure_private_key -u vagrant -i .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory build.yml -t rebuild
- hosts: all
become: true
become_method: sudo
vars:
- yara_version: 1.7
- geoip_version: 1.6.0
- pcap_version: 1.7.4
- curl_version: 7.50.2
- glib2_dir: 2.48
- glib2_version: 2.48.2
- node_version: 0.10.46
- daq_version: 2.0.6
- rvm1_rubies:
- ruby-1.9.3
- iteration: 1
# Tasks before roles install software
pre_tasks:
- block:
- name: ntop repo
get_url: url=http://packages.ntop.org/centos-stable/ntop.repo dest=/etc/yum.repos.d/ntop.repo
- name: epel repo
yum: name=https://dl.fedoraproject.org/pub/epel/epel-release-latest-{{ansible_distribution_major_version}}.noarch.rpm state=installed
# On Centos 6 need to upgrade kernel so we get TPACKET_V3. User doesn't have to have new kernel
- block:
- name: remove old kernel headers
yum: state=absent name=kernel-headers
- name: install new kernel headers
yum: state=present name=http://files.molo.ch/kernel-ml-headers-4.4.0-1.el6.elrepo.x86_64.rpm
# TPACKET_V3 block end
when: ansible_distribution_major_version == "6"
tags: kernel
- yum: name={{item}} state=installed
with_items:
- git
- wget
- curl
- pcre
- pcre-devel
- pkgconfig
- flex
- bison
- gcc
- gcc-c++
- zlib-devel
- e2fsprogs-devel
- openssl-devel
- file-devel
- make
- gettext
- libuuid-devel
- perl-JSON
- bzip2-libs
- bzip2-devel
- perl-libwww-perl
- libpng-devel
- xz
- libffi-devel
- libselinux-python
- rpm-build
- pfring
# Block end
when: ansible_distribution=='CentOS'
- block:
#- apt: deb=http://packages.ntop.org/apt-stable/{{ansible_distribution_version}}/all/apt-ntop-stable.deb
- name: ntop deb
apt: deb=http://apt-stable.ntop.org/{{ansible_distribution_version}}/all/apt-ntop-stable.deb
- apt: update_cache=yes name={{item}} state=installed
with_items:
- git
- wget
- curl
- libpcre3-dev
- uuid-dev
- libmagic-dev
- pkg-config
- gcc
- g++
- flex
- bison
- zlib1g-dev
- libffi-dev
- gettext
- make
- libjson-perl
- libbz2-dev
- libwww-perl
- libpng-dev
- xz-utils
- libffi-dev
- libssl-dev
- pfring
# Block end
when: ansible_distribution == 'Ubuntu'
# Wackiness is happening where it doesn't always resolve and stuff
- name: keys.gnupg.net hosts entry hack
lineinfile: dest=/etc/hosts line="178.32.66.144 keys.gnupg.net"
# Install ruby
roles:
- {role: rvm_io.rvm1-ruby}
# Tasks after roles
tasks:
- name: install fpm
gem: name=fpm user_install=no state=latest executable=/usr/local/bin/gem
# Prepare prereqs
- name: Download Packages
get_url: url={{item}} dest=. validate_certs=no
with_items:
- https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/yara-project/yara-{{yara_version}}.tar.gz
- http://www.maxmind.com/download/geoip/api/c/GeoIP-{{geoip_version}}.tar.gz
- http://www.tcpdump.org/release/libpcap-{{pcap_version}}.tar.gz
- http://curl.haxx.se/download/curl-{{curl_version}}.tar.gz
- http://ftp.gnome.org/pub/gnome/sources/glib/{{glib2_dir}}/glib-{{glib2_version}}.tar.xz
- https://nodejs.org/download/release/v{{node_version}}/node-v{{node_version}}-linux-x64.tar.xz
- https://www.snort.org/downloads/snort/daq-{{daq_version}}.tar.gz
- name: Unarchive Packages
unarchive: src={{item}} dest=. copy=no
with_items:
- yara-{{yara_version}}.tar.gz
- GeoIP-{{geoip_version}}.tar.gz
- libpcap-{{pcap_version}}.tar.gz
- curl-{{curl_version}}.tar.gz
- glib-{{glib2_version}}.tar.xz
- daq-{{daq_version}}.tar.gz
- name: Check yara
stat: path=yara-{{yara_version}}/libyara/.libs/libyara.a
register: st
- name: Build yara
shell: cd yara-{{yara_version}}; ./configure --enable-static; make
when: st.stat.exists == False
- name: Check GeoIP
stat: path=GeoIP-{{geoip_version}}/libGeoIP/.libs/libGeoIP.a
register: st
- name: Build GeoIP
shell: cd GeoIP-{{geoip_version}}; ./configure --enable-static; make
when: st.stat.exists == False
- name: Check libpcap
stat: path=libpcap-{{pcap_version}}/libpcap.a
register: st
- name: Build libpcap
shell: cd libpcap-{{pcap_version}}; ./configure --disable-dbus --disable-usb --disable-canusb --disable-bluetooth; make
when: st.stat.exists == False
- name: Check curl
stat: path=curl-{{curl_version}}/lib/.libs/libcurl.a
register: st
- name: Build curl
shell: cd curl-{{curl_version}}; ./configure --disable-ldap --disable-ldaps --without-libidn --without-librtmp; make
when: st.stat.exists == False
- name: Check glib2
stat: path=glib-{{glib2_version}}/glib/.libs/libglib-2.0.a
register: st
- name: Build glib2
shell: cd glib-{{glib2_version}}; ./configure --disable-xattr --disable-shared --enable-static --disable-libelf --disable-selinux --with-pcre=internal; make
when: st.stat.exists == False
- name: Check daq
stat: path=/usr/local/include/daq.h
register: st
- name: Build daq
shell: cd daq-{{daq_version}}; ./configure --with-libpcap-includes=/home/vagrant/libpcap-1.7.4/ --with-libpcap-libraries=/home/vagrant/libpcap-1.7.4; make; make install
when: st.stat.exists == False
# Only install snf if it exists locally.
- name: Check for remote snf
stat: path=/opt/snf
register: remotesnf
- name: Check for local snf
become: false
local_action: stat path=snf.tgz
register: localsnf
tags:
- rebuild
- name: unarchive snf
unarchive: src=snf.tgz dest=/opt
when: localsnf.stat.exists == True and remotesnf.stat.exists == False
- name: rename snf
command: mv /opt/myri_snf-3.0.9.50782_d4d3de8ea-3342.x86_64 /opt/snf
when: localsnf.stat.exists == True and remotesnf.stat.exists == False
# Prepare build
- name: Remove old dest directory
file: dest=/data/moloch state=absent
- name: Create dest directory
file: dest=/data/moloch/{{item}} state=directory owner=nobody
with_items:
- etc
- bin
- logs
- name: Create raw directory
file: dest=/data/moloch/raw state=directory owner=nobody mode=0700
- name: Unarchive node
unarchive: src=~vagrant/node-v{{node_version}}-linux-x64.tar.xz dest=/data/moloch copy=no
- name: node link
file: state=link src=/data/moloch/node-v{{node_version}}-linux-x64/bin/{{item}} dest=/data/moloch/bin/{{item}}
with_items:
- node
- npm
# Actually build
- block:
- name: git clone
git: repo=https://github.com/aol/moloch dest=moloch update=yes force=yes
- name: configure
shell: cd moloch; ./configure --with-libpcap=../libpcap-{{pcap_version}} --with-yara=../yara-{{yara_version}} --with-GeoIP=../GeoIP-{{geoip_version}} --with-curl=../curl-{{curl_version}} --with-glib2=../glib-{{glib2_version}}
- name: clean build area
shell: cd moloch; make clean
- name: build
shell: cd moloch; make
- name: build pfring plugin
shell: cd moloch/capture/plugins/pfring; make
- name: build daq plugin
shell: cd moloch/capture/plugins/daq; make
- name: build snf plugin
shell: cd moloch/capture/plugins/snf; make
when: localsnf.stat.exists == True
- name: install
shell: cd moloch; make install
environment:
PATH: "/data/moloch/bin:{{ansible_env.PATH}}"
# Block End
tags:
- rebuild
- name: copy sample config
copy: src=../config.ini dest=/data/moloch/etc/config.ini.sample
- name: copy upstart files
copy: src="{{item}}" dest=/data/moloch/etc/
with_items:
- molochcapture.upstart.conf
- molochviewer.upstart.conf
- molochwise.upstart.conf
- elasticsearch.upstart.conf
- logging.demo.yml
- elasticsearch.demo.yml
- copy: src="README.txt" dest=/data/moloch/
- name: helper scripts
copy: src={{item}} dest=/data/moloch/bin mode=0755
with_items:
- moloch_update_geo.sh
- moloch_add_user.sh
- Configure
- set_fact:
moloch_version: "stoperrors"
# CentOS package
- block:
- name: get moloch version
shell: sed 's/.*\"\(.*\)\".*$/\1/' moloch/viewer/version.js | tr "-" "_"
register: moloch_version_cmd_centos
- set_fact:
moloch_version: "{{moloch_version_cmd_centos.stdout}}"
- name: fpm centos
shell: bash -lc "{{item}}"
with_items:
- fpm -s dir -t rpm -n moloch -v {{moloch_version}} --iteration {{iteration}} /data/moloch
- name: copy centos back
fetch: src=moloch-{{moloch_version}}-{{iteration}}.x86_64.rpm dest=./builds
# Block end
when: ansible_distribution=='CentOS'
tags: package
# Ubuntu package
- block:
- name: get moloch version
shell: sed 's/.*\"\(.*\)\".*$/\1/' moloch/viewer/version.js
register: moloch_version_cmd_ubuntu
- set_fact:
moloch_version: "{{moloch_version_cmd_ubuntu.stdout}}"
- name: fpm ubuntu
shell: bash -lc "{{item}}"
with_items:
- fpm -s dir -t deb -n moloch -v {{moloch_version}} --iteration {{iteration}} /data/moloch
- name: copy ubuntu back
fetch: src=moloch_{{moloch_version}}-{{iteration}}_amd64.deb dest=./builds
# Block end
when: ansible_distribution=='Ubuntu'
tags: package