-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmininet.yml
231 lines (168 loc) · 5.18 KB
/
mininet.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
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
##installation of Network Emulator (Mininet), and all the dependencies
---
- hosts: mininet_machine
become: yes
become_method: sudo
become_user: root
tasks:
- name: Get home directory of the user
shell: "getent passwd {{ ansible_user }} | cut -d: -f6"
register: user_home
- name: Print home directory
debug:
var: user_home.stdout
- name: Install required packages
apt:
name: "{{ item }}"
state: present
loop:
- gcc
- perl
- make
- terminator
- openjdk-11-jdk
- git
- git-review
- zip
- curl
- unzip
- bzip2
- python2-dev
- python-setuptools
- python3-dev
- python3-setuptools
- python3-pip
- xterm
- default-jdk
- python3
- snapd
- name: Add Java environment variables
lineinfile:
dest: /etc/environment
line: |
JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
JRE_HOME=/usr/lib/jvm/java-11-openjdk-amd64/jre
- name: Install Python
apt:
name: python
state: present
- name: Download get-pip.py
get_url:
url: https://bootstrap.pypa.io/pip/2.7/get-pip.py
dest: /tmp/get-pip.py
when: ansible_distribution_major_version|int == 16
- name: Install pip for Python 2
command: python2 /tmp/get-pip.py
when: ansible_distribution_major_version|int == 16
- name: Update Package Manager
command: sudo apt update
- name: Install python3-pip
apt:
name: python3-pip
state: present
- name: Upgrade pip for Python 3
pip:
name: pip
state: latest
executable: pip3
- name: Install Selenium
pip:
name: selenium
state: present
- name: Clone Mininet
command: git clone https://github.com/mininet/mininet /home/ubuntu/mininet
- name: Install Mininet
become: yes
apt:
name: mininet
state: present
- name: Download sFlow-RT tarball
get_url:
url: http://www.inmon.com/products/sFlow-RT/sflow-rt.tar.gz
dest: "{{ user_home.stdout }}/sflow-rt.tar.gz"
- name: Create sFlow-RT directory
become: yes
file:
path: "{{ user_home.stdout }}/sflow-rt"
state: directory
- name: Extract sFlow-RT tarball
become: yes
unarchive:
src: "{{ user_home.stdout }}/sflow-rt.tar.gz"
dest: "{{ user_home.stdout }}/sflow-rt"
remote_src: yes
extra_opts: "--strip-components=1"
- name: Install required sFlow-RT applications
shell: "{{ user_home.stdout }}/sflow-rt/get-app.sh sflow-rt {{ item }}"
args:
chdir: "{{ user_home.stdout }}/sflow-rt"
loop:
- browse-metrics
- active-routes
- browse-drops
- browse-flows
- ddos-protect
- fabric-metrics
- ixp-metrics
- mininet-dashboard
- particle
- prometheus
- sflow-test
- sunburst
- topology
- trace-flow
- world-map
- dashboard-example
- name: Install Java
apt:
name: openjdk-11-jre-headless
state: present
- name: Debug - Before starting sFlow-RT
debug:
msg: "About to start sFlow-RT script"
- name: Start sFlow-RT in the background
shell: "nohup {{ user_home.stdout }}/sflow-rt/start.sh > /dev/null 2>&1 &"
- name: Debug - After starting sFlow-RT
debug:
msg: "sFlow-RT script started successfully"
- name: Retrieve IP address of sflow_machine
set_fact:
sflow_ip: "{{ groups['sflow_machine'][0] }}"
- name: Debug - Print sflow_machine IP address
debug:
var: sflow_ip
- name: Create example.py file
ansible.builtin.template:
src: "{{ example_folder }}/example.py.j2"
dest: "{{ user_home.stdout }}/example.py"
vars:
user_home: "{{ lookup('env', 'HOME') }}"
- name: Debug - Print inventory file
debug:
msg: "{{ lookup('file', '{{ example_folder }}/inventory.ini') }}"
- name: Retrieve IP address of onos_machine
set_fact:
onos_ip: "{{ groups['onos_machine'][0] }}"
- name: Debug - Print onos_machine IP address
debug:
var: onos_ip
- name: Print command to be executed
debug:
msg: "Command to be executed: sudo mn --custom example.py,sflow-rt/extras/sflow.py --topo mytopo --mac --switch=ovs,protocols=OpenFlow13 '--controller=remote,ip={{ onos_ip }}' &"
- name: Update package repositories
apt:
update_cache: yes
- name: Install tmux
apt:
name: tmux
state: present
- name: Create topology.sh file and save it on mininet machine
ansible.builtin.template:
src: "{{ example_folder }}/topology.sh.j2"
dest: "{{ user_home.stdout }}/topology.sh"
vars:
user_home: "{{ lookup('env', 'HOME') }}"
- name: Configure permission to the topology file
shell: chmod +x topology.sh
- name: Start topology in the background
shell: "nohup {{ user_home.stdout }}/topology.sh > /dev/null 2>&1 &"