-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathidentify_scsi_devices.yml
65 lines (55 loc) · 2.05 KB
/
identify_scsi_devices.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
---
- name: Identify filesystems and their corresponding SCSI devices in RedHat Guest OS
hosts: all
become: yes
gather_facts: yes
tasks:
- name: Gather filesystem mount information
ansible.builtin.command:
cmd: df -hT
register: df_output
- name: Display filesystem mount information
ansible.builtin.debug:
var: df_output.stdout_lines
- name: Gather detailed block device information
ansible.builtin.command:
cmd: lsblk -o NAME,HCTL,TYPE,SIZE,MODEL,MOUNTPOINT
register: lsblk_output
- name: Display detailed block device information
ansible.builtin.debug:
var: lsblk_output.stdout_lines
- name: Gather volume group information
ansible.builtin.command:
cmd: vgs --noheadings -o vg_name,pv_name
register: vgs_output
- name: Display volume group information
ansible.builtin.debug:
var: vgs_output.stdout_lines
- name: Gather detailed SCSI device information
ansible.builtin.shell: |
for device in $(ls /dev/disk/by-path/); do
echo "Device: $device"
udevadm info --query=all --name=/dev/disk/by-path/$device
echo ""
done
register: udevadm_output
- name: Display detailed SCSI device information
ansible.builtin.debug:
var: udevadm_output.stdout_lines
- name: Correlate filesystem, VG, and SCSI device information
ansible.builtin.shell: |
echo "Filesystem and SCSI Device Correlation:"
for mp in $(df --output=target | tail -n +2); do
dev=$(df --output=source $mp | tail -n 1)
vg=$(lvdisplay $dev 2>/dev/null | grep "VG Name" | awk '{print $3}')
scsi=$(lsblk -no NAME,HCTL,TYPE,SIZE,MODEL,MOUNTPOINT | grep $mp)
echo "Mount Point: $mp"
echo "Device: $dev"
echo "Volume Group: $vg"
echo "SCSI Info: $scsi"
echo ""
done
register: correlation_output
- name: Display correlated information
ansible.builtin.debug:
var: correlation_output.stdout_lines