Thanks for all the feedback, On my Centos 6.3 machine lspci is located in /sbin/lspci
So i changed it to:
pcidata = None
try:
try:
p = Popen([“/sbin/lspci”], stdout=PIPE)
except:
try:
p = Popen([“/usr/sbin/lspci”], stdout=PIPE)
except:
p = Popen([“lspci”], stdout=PIPE)
err = p.wait()
if err:
print “Error running lspci”
else:
pcidata = p.stdout.read()
except OSError, e:
module.fail_json( msg=“lspci failed %s” % e) # no lspci
https://www.filepicker.io/api/file/nsajpMMqSu2AIjPGC3lA
This is the modified code based on the feedback received, Let me know if i can make it better .
Out put:
s2 | success >> {
“ansible_facts”: {
“device_details”: {
“sda”: {
“disk type”: “Spinning disk”,
“host”: “SATA controller: Intel Corporation 6 Series/C200 Series Chipset Family SATA AHCI Controller (rev 05)”,
“model”: “ST500DM002-1BC14”,
“removable”: “No”,
“sda1”: {
“sectors”: “1024000”,
“size”: “500.00MiB”,
“start sector”: “2048”
},
“sda2”: {
“holders”: [
“VolGroup00-LogVol01”,
“VolGroup00-LogVol00”
],
“sectors”: “975747072”,
“size”: “465.27GiB”,
“start sector”: “1026048”
},
“sector size(bytes)”: “512”,
“sectors”: “976773168”,
“size”: “465.76GiB”,
“support discard”: “No”,
“vendor”: “ATA”
},
“sdb”: {
“disk type”: “SSD”,
“host”: “SATA controller: Intel Corporation 6 Series/C200 Series Chipset Family SATA AHCI Controller (rev 05)”,
“model”: “SAMSUNG SSD 830”,
“removable”: “No”,
“sector size(bytes)”: “512”,
“sectors”: “395093371”,
“size”: “188.40GiB”,
“support discard”: “Yes”,
“vendor”: “ATA”
},
“sdc”: {
“disk type”: “SSD”,
“host”: “SATA controller: Intel Corporation 6 Series/C200 Series Chipset Family SATA AHCI Controller (rev 05)”,
“model”: “SAMSUNG SSD 830”,
“removable”: “No”,
“sector size(bytes)”: “512”,
“sectors”: “395093371”,
“size”: “188.40GiB”,
“support discard”: “Yes”,
“vendor”: “ATA”
}
},
“devices”: [
“sda”,
“sdb”,
“sdc”
]
},
“changed”: false
}
Regards,–
Kavin Kankeshwar