1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fixing logical error in detecting virtual device.

So In my Centos 5.9 machine, if there is RAID mount ansible will crash, as it cannot find scheduler file. The reason being, this should be a virtual device as there is no "device" folder under e.g. /sys/block/md0/

Here is the crash:

[kk@u1 ansible]$ ansible q3 -m setup -k -u root --tree=/tmp/facts
SSH password:
q3 | FAILED => failed to parse: /sys/block/md0
Traceback (most recent call last):
  File "/root/.ansible/tmp/ansible-1360629441.14-171498703486275/setup", line 1797, in ?
    main()
  File "/root/.ansible/tmp/ansible-1360629441.14-171498703486275/setup", line 1050, in main
    data = run_setup(module)
  File "/root/.ansible/tmp/ansible-1360629441.14-171498703486275/setup", line 1000, in run_setup
    facts = ansible_facts()
  File "/root/.ansible/tmp/ansible-1360629441.14-171498703486275/setup", line 990, in ansible_facts
    facts.update(Hardware().populate())
  File "/root/.ansible/tmp/ansible-1360629441.14-171498703486275/setup", line 312, in populate
    self.get_device_facts()
  File "/root/.ansible/tmp/ansible-1360629441.14-171498703486275/setup", line 439, in get_device_facts
    m = re.match(".*?(\[(.*)\])", scheduler)
  File "/usr/lib64/python2.4/sre.py", line 129, in match
    return _compile(pattern, flags).match(string)
TypeError: expected string or buffer
This commit is contained in:
Kavin Kankeshwar 2013-02-11 18:23:58 -08:00
parent af3402fe35
commit 3042366199

View file

@ -387,7 +387,7 @@ class LinuxHardware(Hardware):
return return
for block in block_devs: for block in block_devs:
virtual = 0 virtual = 1
sysfs_no_links = 0 sysfs_no_links = 0
try: try:
path = os.readlink(os.path.join("/sys/block/", block)) path = os.readlink(os.path.join("/sys/block/", block))
@ -403,7 +403,7 @@ class LinuxHardware(Hardware):
if sysfs_no_links == 1: if sysfs_no_links == 1:
for folder in os.listdir(sysdir): for folder in os.listdir(sysdir):
if re.search("device", folder): if re.search("device", folder):
virtual = 1 virtual = 0
break break
if virtual: if virtual:
continue continue