summaryrefslogtreecommitdiffstats
path: root/resources/ansible_roles/nDPI/tasks/main.yml
blob: 6dc7bf9dd62d39b55a5c9fa9b1de336a6142b29b (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
##############################################################################
# Copyright (c) 2017 ZTE Corporation and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################

---

- name: making nDPI temporary directory
  file:
    path: "{{ workdir }}"
    state: directory

- name: downloading nDPI
  get_url:
    url: https://github.com/ntop/nDPI/archive/1.6.tar.gz
    dest: "{{ workdir }}"
    checksum: "sha256:0863c7096f70c785e1b27a34f7b40939ac1a0e3a734ea3dcaa5cf161360a2561"

- name: extracting nDPI
  command: "tar zxf nDPI-1.6.tar.gz"
  args:
    chdir: "{{ workdir }}"
    creates: nDPI-1.6

- name: build nDPI library
  command: '{{ item }}'
  with_items:
    - ./autogen.sh
    - ./configure
    - make
  args:
    chdir: "{{ workdir }}/nDPI-1.6"
    creates: example/ndpiReader

- name: downloading sample pcap file
  get_url:
    url: "https://build.opnfv.org/artifacts.opnfv.org/qtip/utilities/test.pcap"
    dest: "{{ workdir }}/nDPI-1.6/example/{{ sample_pcap }}"
    checksum: "sha256:ac5d1501d91a6d8a8d3bfcef6f74a87bf660cd2c2ab11b9791535aa5193e4f71"
    validate_certs: no  # required when using proxy for https

- name: measuring dpi performance
  command: "./ndpiReader -i {{ sample_pcap }}"
  args:
    chdir: "{{ workdir }}/nDPI-1.6/example/"
  register: ndpi_out

- name: saving output to log
  copy:
    content: "{{ ndpi_out.stdout }}"
    dest: "{{ logfile }}"
  delegate_to: localhost

- name: collecting DPI metrics
  collect:
    string: "{{ lookup('file', logfile) }}"
    patterns:
      # 	nDPI throughput:       1.46 M pps / 13.69 Gb/sec
      # TODO(yujunz) convert "M pps" and "K pps" to number
      - 'nDPI throughput:\s+?(?P<dpi_pps>\d+.\d+.*) \/ (?P<dpi_bps>\d+.\d+.*)$'
    dest: "{{ output }}/metrics.json"
  register: dpi_metrics
  delegate_to: localhost

- name: create dpi report
  template:
    src: dpi-metrics.j2
    dest: "{{ output }}/dpi-metrics"
  delegate_to: localhost