-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmultisetup-latency.yml
118 lines (98 loc) · 2.96 KB
/
multisetup-latency.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
---
- name: latency setup
hosts: all
remote_user: root
tags:
- latency
tasks:
- name: Check that network latency is specified
assert:
that:
- latency is defined
- latency | int | string == latency
fail_msg: "you need to define latency variable as one way connection delay in seconds"
- debug:
var: latency
- debug:
var: latency_spec
- name: Transform latency_spec for the network-latency.sh script
set_fact:
latency_spec_opts: "-l {{ latency_spec.items() | map('join', '=') | join(' -l ') }}"
when: latency_spec is defined
- name: Set empty latency_spec for the network-latency.sh script
set_fact:
latency_spec_opts: ""
when: latency_spec is not defined
- debug:
var: latency_spec_opts
- name: Install tc dependencies for latency setup
dnf:
name:
- iproute-tc
- kernel-modules-extra
state: present
- name: Install yum utils for needs-restarting plugin
dnf:
name: yum-utils
state: present
- name: Check if a reboot is needed
ansible.builtin.command: needs-restarting -r
register: needs_restarting
changed_when: needs_restarting.rc != 0
ignore_errors: yes
failed_when: false
- name: Reboot after update if needed
when: needs_restarting.changed
block:
- name: Reboot node
shell: sleep 5 && reboot
async: 1
poll: 0
- name: Wait for the reboot to complete
wait_for_connection:
connect_timeout: 10
sleep: 10
delay: 30
timeout: 7200
- ping:
any_errors_fatal: True
- name: Add sch_netem into modules-load.d
ansible.builtin.copy:
dest: "/etc/modules-load.d/sch_netem.conf"
content: "sch_netem"
owner: root
group: root
- name: Modprobe sch_netem module
community.general.modprobe:
name: sch_netem
state: present
- name: Copy latency script
copy:
src: "ocpnetsplit/network-latency.sh"
dest: "/etc/network-latency.sh"
owner: root
group: root
mode: 0544
- name: Copy pingtest script for debugging latency on nodes
copy:
src: "ocpnetsplit/network-pingtest.sh"
dest: "/etc/network-pingtest.sh"
owner: root
group: root
mode: 0544
- name: Copy latency unit file
ansible.builtin.template:
src: "ocpnetsplit/systemd/network-latency.service"
dest: "/etc/systemd/system/network-latency.service"
owner: root
group: root
register: latency_unit_file
- name: Daemon reload
ansible.builtin.systemd:
daemon_reload: true
when: latency_unit_file.changed
- name: Restart and enable the latency service
ansible.builtin.systemd:
name: network-latency
enabled: true
state: restarted