forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fail early if any locally attached physical disks are not ok
Flash memory storage can also fail, typically when erase cycles have exceeded a threshold. In this commit we add a fixture that checks all locally attached physical disks across all nodes, via smartctl, and fails if the self-assessment result is not OK. This check can be skipped through the FIXTURES env var. Relates: elastic#153
- Loading branch information
Showing
6 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
night_rally/fixtures/ansible/playbooks/check-drive-health.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
|
||
# NOTE: This is also a fixture, but needs to target all hosts, so doesn't live under setup.yml | ||
- name: check disk health on all hosts | ||
# ==================================== | ||
hosts: all | ||
gather_facts: true | ||
roles: | ||
- { role: check-drive-health, tags: check-drive-health } |
1 change: 1 addition & 0 deletions
1
night_rally/fixtures/ansible/roles/check-drive-health/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Role to check health of locally attached physical disks via smartctl |
9 changes: 9 additions & 0 deletions
9
night_rally/fixtures/ansible/roles/check-drive-health/tasks/common/check_health.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
|
||
- name: Fail if any locally attached disks don't pass the smartctl health check | ||
command: smartctl -a /dev/{{ item.name }} | ||
register: smartctloutput | ||
failed_when: "'SMART overall-health self-assessment test result: PASSED' not in smartctloutput.stdout" | ||
changed_when: false | ||
loop: "{{ (phys_disks.stdout | from_json).blockdevices | flatten(levels=1) }}" | ||
when: not in_vagrant | default("false") | bool |
13 changes: 13 additions & 0 deletions
13
night_rally/fixtures/ansible/roles/check-drive-health/tasks/debian/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
|
||
- name: Install system packages for lsblk and smartctl | ||
package: | ||
name: "{{ item }}" | ||
state: present | ||
loop: | ||
- util-linux | ||
- smartmontools | ||
|
||
- name: Retrieve list of locally attached physical disks | ||
shell: lsblk --json --nodeps | ||
register: phys_disks |
14 changes: 14 additions & 0 deletions
14
night_rally/fixtures/ansible/roles/check-drive-health/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
|
||
- set_fact: | ||
system_tasks: "{{ lookup('first_found', params) }}" | ||
vars: | ||
params: | ||
files: | ||
- "{{ ansible_os_family | lower }}/main.yml" | ||
- unsupported.yml | ||
|
||
- block: | ||
- include_tasks: "{{ system_tasks }}" | ||
- include_tasks: "common/check_health.yml" | ||
become: true |