-
Notifications
You must be signed in to change notification settings - Fork 21
/
install_comnetsemu.yml
132 lines (113 loc) · 3.87 KB
/
install_comnetsemu.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
#
# About: Install ComNetsEmu and ALL dependencies using Ansible
#
---
- name: Install ComNetsEmu
hosts: all
gather_facts: true
vars:
# The directory where comnetsemu's source code is located.
# Use relative path
TOP_DIR: "../../../"
tasks:
- name: Create directories
file:
path: "{{ item }}"
state: directory
with_items:
- "{{ TOP_DIR }}/comnetsemu_dependencies"
- name: Find deprecated/unused directories and files created by the older ComNetsEmu installer
find:
paths: "{{ TOP_DIR }}/comnetsemu_dependencies"
# Old ComNetsEmu installer fetch some source code dependencies manually and append the versions
# as suffix... They should be removed and use Ansible's way to do it.
patterns:
- "docker-*"
- "mininet-*"
- "ryu-*"
file_type: directory
register: directories_to_remove
- name: Delete deprecated/unused directories and files created by the older ComNetsEmu installer
file:
path: "{{ item.path }}"
state: absent
with_items: "{{ directories_to_remove.files }}"
- name: Update apt-get repo and cache
become: true
apt: update_cache=yes force_apt_get=yes cache_valid_time=3600
- name: Clone Mininet repo
git:
repo: https://github.com/mininet/mininet
dest: "{{ TOP_DIR }}/comnetsemu_dependencies/mininet"
# Unreleased version 2.3.1b1
# This version is needed because it replace all git URLs to https!
version: aa0176fce6fb718a03474f8719261b07b670d30d
force: yes
# Patch source code directly, instead of using runtime monkey patching
- name: Patch Mininet source code
patch:
src: "{{ TOP_DIR }}/comnetsemu/patch/mininet/util.py.patch"
dest: "{{ TOP_DIR }}/comnetsemu_dependencies/mininet/mininet/util.py"
- name: Remove installed openflow directory to force re-install
file:
path: "{{ TOP_DIR }}/comnetsemu_dependencies/openflow"
state: absent
- name: Install Mininet and its minimal dependencies
shell: PYTHON=python3 ./install.sh -nfvw
args:
chdir: "{{ TOP_DIR }}/comnetsemu_dependencies/mininet/util"
- name: Install all deb packages required by ComNetsEmu from the official Ubuntu repo
become: true
apt:
name:
- docker.io
- linux-headers-{{ ansible_kernel }}
- python3-docker
- python3-libtmux
- python3-pip
- python3-pyroute2
- python3-requests
- python3-ryu
- rt-tests
- stress-ng
- tmux
- wireguard
state: latest
- name: Install the ComNetsEmu Python package
become: true
shell: pip3 install .
args:
chdir: "{{ TOP_DIR }}/comnetsemu"
- name: Build all test containers for ComNetsEmu (required for unit tests and some built-in examples)
become: true
shell: python3 ./build.py
args:
chdir: "{{ TOP_DIR }}/comnetsemu/test_containers"
# You can comment out tasks related to install development packages if you don't want to modify or extend
# the source code of ComNetsEmu and build the HTML documentation locally.
- name: Install packages required for the development of ComNetsEmu
become: true
apt:
name:
- black
- pylint
- python3-coverage
- python3-flake8
- python3-ipdb
- python3-pytest
- shellcheck
state: latest
# TODO: Install P4 related dependencies
# TODO: Install a high-performance data plane solutions e.g. VPP or OVS-DPDK
- name: Install packages required to build HTML documentation of ComNetsEmu
become: true
# Pip must be used here since many required packages are not currently in Ubuntu's repo.
shell: pip3 install -r ./requirements.txt
args:
chdir: "{{ TOP_DIR }}/comnetsemu/doc"
- name: Start and enable the Docker service
become: true
systemd:
name: docker
state: started
enabled: yes