diff --git a/playbooks/ansible/client-test.yml b/playbooks/ansible/client-test.yml index f4346ab1..32bfc711 100644 --- a/playbooks/ansible/client-test.yml +++ b/playbooks/ansible/client-test.yml @@ -1,5 +1,5 @@ --- -- hosts: clients +- hosts: all become: yes become_method: sudo vars_files: diff --git a/playbooks/ansible/roles/monitor/tasks/start.yml b/playbooks/ansible/roles/monitor/tasks/start.yml new file mode 100644 index 00000000..caae5057 --- /dev/null +++ b/playbooks/ansible/roles/monitor/tasks/start.yml @@ -0,0 +1,15 @@ +--- +- name: Stop monitoring if enabled + include_tasks: stop.yml + +- name: Launch background sadc monitoring + shell: + executable: /bin/bash + cmd: >- + nohup /usr/lib64/sa/sadc -S XALL 1 /dev/null + > >(nohup xz - >{{ config.statedir }}/sadc_{{ name }}.xz 2>/dev/null) & + echo ${!} >/tmp/sadc.pid + +- name: Wait few seconds to monitor idle activity + pause: + seconds: 5 diff --git a/playbooks/ansible/roles/monitor/tasks/stop.yml b/playbooks/ansible/roles/monitor/tasks/stop.yml new file mode 100644 index 00000000..143d0913 --- /dev/null +++ b/playbooks/ansible/roles/monitor/tasks/stop.yml @@ -0,0 +1,20 @@ +--- +- name: Check if sadc is running + stat: + path: /tmp/sadc.pid + get_attributes: false + get_checksum: false + get_mime: false + register: sadc_pid + +- name: Stop sadc if running + when: sadc_pid.stat.exists + block: + - name: Wait few seconds to monitor idle activity + pause: + seconds: 5 + + - name: Stop sadc + shell: + executable: /bin/bash + cmd: "kill -TERM $(cat /tmp/sadc.pid) && rm -f /tmp/sadc.pid" diff --git a/playbooks/ansible/roles/tests/tasks/run-test.yml b/playbooks/ansible/roles/tests/tasks/run-test.yml index 6a83ecaa..805b5d08 100644 --- a/playbooks/ansible/roles/tests/tasks/run-test.yml +++ b/playbooks/ansible/roles/tests/tasks/run-test.yml @@ -5,18 +5,27 @@ line: "PREPARING {{ role }}" - name: Prepare test {{ role }} + when: inventory_hostname in groups['clients'] include_role: name: "{{ role }}" tasks_from: prepare/main.yml - name: Process test {{ role }} block: + - name: Start monitoring + include_role: + name: monitor + tasks_from: start.yml + vars: + name: "{{ role }}" + - name: Log test start time include_tasks: log.yml vars: line: "RUNNING {{ role }}" - name: Run test {{ role }} + when: inventory_hostname in groups['clients'] include_role: name: "{{ role }}" @@ -27,6 +36,7 @@ line: "RECOVERING {{ role }}" - name: Recover from failure of {{ role }} + when: inventory_hostname in groups['clients'] include_role: name: "{{ role }}" tasks_from: recover/main.yml @@ -41,7 +51,13 @@ vars: line: "FINISHED {{ role }}" + - name: Stop monitoring + include_role: + name: monitor + tasks_from: stop.yml + - name: Cleanup for {{ role }} + when: inventory_hostname in groups['clients'] include_role: name: "{{ role }}" tasks_from: cleanup/main.yml diff --git a/playbooks/hosts.update.yml b/playbooks/hosts.update.yml index d51a2957..70079ef3 100644 --- a/playbooks/hosts.update.yml +++ b/playbooks/hosts.update.yml @@ -9,3 +9,4 @@ - ansible/config.yml roles: - hosts.update + - monitor diff --git a/playbooks/roles/monitor/tasks/main.yml b/playbooks/roles/monitor/tasks/main.yml new file mode 100644 index 00000000..59114052 --- /dev/null +++ b/playbooks/roles/monitor/tasks/main.yml @@ -0,0 +1,21 @@ +--- +- name: Install sysstat + yum: + name: sysstat + state: latest + +- name: Disable sysstat service and timers + systemd: + name: "{{ item }}" + enabled: false + masked: true + state: stopped + loop: + - sysstat + - sysstat-collect.timer + - sysstat-summary.timer + +- name: Make sure statedir is present + file: + path: "{{ config.statedir }}" + state: directory