-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbenchmark.yaml
95 lines (90 loc) · 2.12 KB
/
benchmark.yaml
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
- name: Generate timestamp
tags: [always]
hosts: localhost
connection: local
tasks:
- set_fact:
timestamp: "{{ ansible_date_time.iso8601_basic_short}}"
- name: Set common facts
tags: [always]
hosts: all
connection: ssh
tasks:
- set_fact:
work_dir: "/home/ubuntu"
- set_fact:
instance_type: "{{ hostvars[inventory_hostname]['instance_type'] | replace('.', '_') }}"
timestamp: "{{ hostvars['localhost']['timestamp'] }}"
- name: General setup
tags: [prepare]
hosts: all
connection: ssh
become: true
tasks:
- name: Update and upgrade apt packages
apt:
update_cache: yes
upgrade: yes
cache_valid_time: 86400
- name: Install required packages
apt:
name:
- fio
- sysstat
state: present
- name: Reboot
tags: [never]
hosts: all
connection: ssh
become: true
tasks:
- reboot:
- name: Run benchmark
tags: [run]
hosts: all
connection: ssh
become: true
tasks:
- name: Prepare result directory
file:
path: "{{ work_dir }}/result/{{ timestamp }}/"
state: directory
mode: 0755
- set_fact:
result_dir: "{{ work_dir }}/result/{{ timestamp }}"
- name: Set up fio config
template:
src: fio.cfg.tpl
dest: "{{ work_dir }}/fio.cfg"
mode: 0644
- name: Disk benchmarks
shell: |
fio fio.cfg --output-format=json+ --output={{ result_dir }}/{{ instance_type }}.json
args:
executable: /bin/bash
chdir: "{{ work_dir }}"
- shell: find . -name "*.json" -type f -size +0 | sed 's/^\.\///'
args:
executable: /bin/bash
chdir: "{{ result_dir }}"
register: result_files
- name: Fetch results
fetch:
src: "{{ result_dir }}/{{ item }}"
dest: "./result/{{ timestamp }}/"
flat: yes
with_items: "{{ result_files.stdout_lines }}"
- name: Summarize results
tags: [run]
hosts: localhost
connection: local
tasks:
- name: Summarize results
command:
argv:
- /usr/bin/python3
- ./summarize.py
- ./result/{{ timestamp }}
register: summarize_result
- debug:
msg: "{{ summarize_result.stdout_lines }}"