-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiskspace.yml
41 lines (40 loc) · 1.52 KB
/
diskspace.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
- name: Check disk space
hosts: all
become: true
tasks:
- name: Check disk space on Linux
block:
- name: Check if the system is CentOS
set_fact:
is_centos: "{{ ansible_distribution | lower == 'centos' }}"
ignore_errors: true
- name: Check if the system is Ubuntu
set_fact:
is_ubuntu: "{{ ansible_distribution | lower == 'ubuntu' }}"
ignore_errors: true
- name: Check disk space on CentOS
command: df -hT
when: is_centos | bool
register: centos_disk_space
- name: Check disk space on Ubuntu
command: df -hT
when: is_ubuntu | bool
register: ubuntu_disk_space
- name: Print disk space on CentOS
debug:
msg: "{{ centos_disk_space.stdout_lines }}"
when: is_centos | bool
- name: Print disk space on Ubuntu
debug:
msg: "{{ ubuntu_disk_space.stdout_lines }}"
when: is_ubuntu | bool
when: "ansible_os_family == 'RedHat' or ansible_os_family == 'Debian'"
- name: Check disk space on Windows
block:
- name: Check disk space on Windows
win_shell: Get-Volume | Select-Object -Property DriveLetter, FileSystemLabel, FileSystem, SizeRemaining, Size | ConvertTo-Csv -NoTypeInformation
register: windows_disk_space
- name: Print disk space on Windows
debug:
msg: "{{ windows_disk_space.stdout_lines }}"
when: ansible_os_family == 'Windows'