aboutsummaryrefslogtreecommitdiffstats
path: root/ansible/roles/gsm-tester/tasks/main.yml
blob: 309c187c59a49f66a80475722791271d28d055f7 (plain)
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
272
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
---
# gsm tester would only need the libraries, not the dev packages.
# But the name of the -dev packages are more stable over multiple release.

- name: update apt
  apt:
    cache_valid_time: 3600
    update_cache: yes

- name: install osmocom runtime dependencies
  apt:
    name: "{{ item }}"
  with_items:
    - build-essential
    - git
    - automake
    - libdbi-dev
    - libdbd-sqlite3
    - sqlite3
    - libsctp-dev
    - libortp-dev
    - libpcap-dev
    - libc-ares-dev
    - libtool
    - shtool
    - pkg-config
    - libtalloc-dev
    - libpcsclite-dev
    - libgnutls28-dev
    - libmnl-dev
    - libssl-dev
    - libczmq-dev
    - libsofia-sip-ua-glib-dev
    - libsqlite3-dev
    - libasound2-dev
    - liblua5.3-dev
    - lua-socket

# mdbus2 is not available in debian10. TODO: compile it for >9
- name: install mdbus2
  apt:
    name: "{{ item }}"
  with_items:
    - mdbus2
  when: ansible_distribution == 'Debian' and ansible_distribution_version <= '9'

- name: install srsLTE runtime dependencies
  apt:
    name: "{{ item }}"
  with_items:
    - cmake
    - libfftw3-dev
    - libmbedtls-dev
    - libboost-program-options-dev
    - libconfig++-dev
    - libsctp-dev
    - libpcsclite-dev
    - libuhd-dev
    - libczmq-dev

- name: install ofono build dependencies
  apt:
    name: ofono
    state: build-dep

- name: install libqmi-glib a dependency of sysmocom ofono
  apt:
    name: libqmi-glib-dev

- name: install uhub dependencies
  apt:
    name: "{{ item }}"
  with_items:
    - libusb-1.0-0-dev

- name: setup uhubctl repository
  git:
    repo: "https://github.com/mvp/uhubctl.git"
    dest: /root/uhubctl
    version: master
    clone: yes
    update: no

- name: build uhubctl
  shell: |
      make && \
      make install
  args:
    chdir: /root/uhubctl
    creates: /usr/sbin/uhubctl

# TODO: move this into restart-modems.d directory
- name: copy quad_modem_power_cycle.sh
  template:
    src: quad_modem_power_cycle.sh
    dest: /usr/local/bin/quad_modem_power_cycle.sh
    mode: 0755
  tags:
    - ofono

- name: setup ofono repository
  git:
    repo: 'git://git.sysmocom.de/ofono'
    dest: /root/ofono
    version: osmo-gsm-tester
    clone: yes
    update: no
  tags:
    - ofono

- name: build ofono
  shell: |
      ./bootstrap && \
      CFLAGS="-g" ./configure --disable-bluez4 && \
      CFLAGS="-g" make -j3 && \
      make install && \
      systemctl daemon-reload
  args:
    chdir: /root/ofono
    creates: /usr/local/sbin/ofonod
  tags:
    - ofono

- name: ensure ofono is started
  service:
    name: ofono
    state: started
    enabled: yes
  tags:
    - ofono

# patchelf 0.9 available in debian has bugs with certain binaries. Version 0.10
# fails on other binaries, so we need both 0.9 and 0.10 versions installed.
- name: setup patchelf v0.10 repository
  git:
    repo: 'https://github.com/NixOS/patchelf.git'
    dest: /root/patchelf
    version: "0.10"
    clone: yes
    update: no
  tags:
    - patchelf

- name: build patchelf v0.10
  shell: |
      autoreconf -fi && \
      ./configure --prefix=/opt && \
      make && \
      mkdir -p /opt/bin/ && \
      cp src/patchelf /opt/bin/patchelf-v0.10
  args:
    chdir: /root/patchelf
    creates: /opt/bin/patchelf-v0.10
  tags:
    - patchelf

- name: install gsm tester dependencies
  apt:
    name: "{{ item }}"
  with_items:
    - dbus
    - tcpdump
    - sqlite3
    - python3
    - python3-setuptools
    - python3-yaml
    - python3-mako
    - python3-gi
    - ofono
    - patchelf
    - sudo
    - libcap2-bin
    - python3-pip
    - udhcpc
    - iperf3

- name: install gsm tester pip dependencies
  pip:
    name: "{{ item }}"
    executable: pip3
    editable: no
  with_items:
    - "git+https://github.com/podshumok/python-smpplib.git@master#egg=smpplib"
    - pydbus
    - pyusb
    - pysispm
  tags: [pip]

- name: create group osmo-gsm-tester
  group:
    name: osmo-gsm-tester

- name: add jenkins to osmo-gsm-tester and systemd-journal
  user:
    name: jenkins
    groups: "{{ item }}"
    append: yes
    shell: /bin/bash
  with_items:
    - systemd-journal
    - osmo-gsm-tester
    - dialout

- name: setup state directory
  file:
    path: /var/tmp/osmo-gsm-tester/state
    state: directory
    group: osmo-gsm-tester
    mode: g+rwxs

- name: install acl
  apt:
    name: acl

# Ensure the group always has access to all files
- name: add acl to state directory
  acl:
    path: /var/tmp/osmo-gsm-tester/state
    state: present
    etype: group
    entity: osmo-gsm-tester
    default: yes
    permissions: rwx

- name: create trials directory
  file:
    path: /var/tmp/osmo-gsm-tester/trials
    state: directory
    group: osmo-gsm-tester
    mode: g+rwxs

- name: allow osmo-gsm-tester to access ofono
  copy:
    src: dbus_osmo-gsm-tester.conf
    dest: /etc/dbus-1/system.d/osmo-gsm-tester.conf

- name: ensure tcpdump can be called by osmo-gsm-tester
  file:
    path: /usr/sbin/tcpdump
    group: osmo-gsm-tester
    mode: 0750

- name: create a symlink for tcpdump
  file:
    src: /usr/sbin/tcpdump
    dest: /usr/local/bin/tcpdump
    state: link

- name: add correct capabilities to tcpdump
  capabilities:
    path: /usr/sbin/tcpdump
    capability: cap_net_raw,cap_net_admin=eip
    state: present

- name: allow core files for the group osmo-gsm-tester
  copy:
    content: "@osmo-gsm-tester - core unlimited"
    dest: /etc/security/limits.d/osmo-gsm-tester_allowcore.conf

- name: allow rt priority for the group osmo-gsm-tester
  copy:
    content: "@osmo-gsm-tester - rtprio 99"
    dest: /etc/security/limits.d/osmo-gsm-tester_rtprio.conf

- name: setup osmo-gsm-tester repository
  git:
    repo: 'git://git.osmocom.org/osmo-gsm-tester'
    dest: /root/osmo-gsm-tester
    version: master
    clone: yes
    update: no
  tags:
    - osmo-gsm-tester

- name: Install osmo-gsm-tester script helpers to /usr/local/bin (PATH)
  shell: |
      mkdir -p /usr/local/bin/ && \
      cp utils/bin/*.sh /usr/local/bin/
  args:
    chdir: /root/osmo-gsm-tester
  tags:
    - osmo-gsm-tester

- name: Install osmo-gsm-tester sudoers.d files to /etc/sudoers.d/ (PATH)
  shell: |
      mkdir -p /etc/sudoers.d/ && \
      cp utils/sudoers.d/* /etc/sudoers.d/
  args:
    chdir: /root/osmo-gsm-tester
  tags:
    - osmo-gsm-tester

- name: logrotate limit filesizes to 10M
  copy:
    content: "maxsize 10M"
    dest: /etc/logrotate.d/maxsize

- name: install sispmctl (usb power socket)
  apt:
    name: sispmctl

- name: allow group osmo-gsm-tester to access sispm devices
  copy:
    src: 60-sispmctl.rules
    dest: /etc/udev/rules.d/
  notify: restart udev

- name: allow group osmo-gsm-tester to access LMS devices
  copy:
    src: 64-limesuite.rules
    dest: /etc/udev/rules.d/
  notify: restart udev

- name: use persistent naming for modem network interfaces
  copy:
    src: 70-net-setup-link-modems.rules
    dest: /etc/udev/rules.d/
  notify: restart udev

- name: avoid dhcpcd managing modem interfaces and racing with udev rename
  lineinfile:
    path: /etc/dhcpcd.conf
    regexp: '^denyinterfaces'
    line: 'denyinterfaces ww* r*'