Repository: ansible/ansible

Issue:
Regression in LVM facts - has leading spaces before PV/VG/LV names
##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
setup

##### ANSIBLE VERSION
```
ansible 2.5.0
  config file = None
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible-2.5.0-py2.7.egg/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Aug  2 2016, 04:20:16) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)]

```

##### CONFIGURATION
<!---
default config
-->

##### OS / ENVIRONMENT
<!---
OS: RHEL 7.3
-->

##### SUMMARY
<!--- Explain the problem briefly -->

##### STEPS TO REPRODUCE
<!---
Create a PV/VG/LV
Gather facts.
ansible_lvm.{pvs,lvs,vgs} has leading spaces as part of name
-->

<!--- Paste example playbooks or commands between quotes below -->
```yaml
ansible -m setup -a "filter=ansible_lvm" localhost
```


##### EXPECTED RESULTS
PV/VG/LV names should NOT have leading spaces.

##### ACTUAL RESULTS
<!--- Paste verbatim command output between quotes below -->
```
localhost | SUCCESS => {
    "ansible_facts": {
        "ansible_lvm": {
            "lvs": {
                "  demo": {
                    "size_g": "0.24", 
                    "vg": "vg1"
                }
            "pvs": {
                "  /dev/sda2": {
                    "free_g": "4.65", 
                    "size_g": "34.18", 
                    "vg": "vg0"
                }
            }, 
            "vgs": {
                "  vg0": {
                    "free_g": "4.65", 
                    "num_lvs": "5", 
                    "num_pvs": "1", 
                    "size_g": "34.18"
                }
            }
        }

```



Discussion:
I'm pretty sure this recent commit is the cause of the bug:

https://github.com/ansible/ansible/commit/5065bf169d885c506301b9bcc9439a914f85d254#diff-b2db09772e4a22e4ab5b8de4c3b6d11e
cc @david_obrien
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->

Resolving patch:
diff --git a/lib/ansible/module_utils/facts/hardware/linux.py b/lib/ansible/module_utils/facts/hardware/linux.py
--- a/lib/ansible/module_utils/facts/hardware/linux.py
+++ b/lib/ansible/module_utils/facts/hardware/linux.py
@@ -671,7 +671,7 @@ def get_lvm_facts(self):
             if vgs_path:
                 rc, vg_lines, err = self.module.run_command('%s %s' % (vgs_path, lvm_util_options))
                 for vg_line in vg_lines.splitlines():
-                    items = vg_line.split(',')
+                    items = vg_line.strip().split(',')
                     vgs[items[0]] = {'size_g': items[-2],
                                      'free_g': items[-1],
                                      'num_lvs': items[2],
@@ -684,7 +684,7 @@ def get_lvm_facts(self):
             if lvs_path:
                 rc, lv_lines, err = self.module.run_command('%s %s' % (lvs_path, lvm_util_options))
                 for lv_line in lv_lines.splitlines():
-                    items = lv_line.split(',')
+                    items = lv_line.strip().split(',')
                     lvs[items[0]] = {'size_g': items[3], 'vg': items[1]}
 
             pvs_path = self.module.get_bin_path('pvs')
@@ -693,7 +693,7 @@ def get_lvm_facts(self):
             if pvs_path:
                 rc, pv_lines, err = self.module.run_command('%s %s' % (pvs_path, lvm_util_options))
                 for pv_line in pv_lines.splitlines():
-                    items = pv_line.split(',')
+                    items = pv_line.strip().split(',')
                     pvs[self._find_mapper_device_name(items[0])] = {
                         'size_g': items[4],
                         'free_g': items[5],


Test patch: