community.general/lib/ansible
Hugh Saunders f344ec463f Add LVM facts to setup module
This commit adds LinuxHardware.get_device_facts() and calls that from
.populate().

LVM facts are only gathered if the setup module is running as root and
the lvm utilities are available (tested by searching for 'vgs').

If the conditions are met, facts are set for each volume group and
logical volume.

Example:

Test LVM Data:
$ sudo vgs
  VG   #PV #LV #SN Attr   VSize VFree
  test   1   2   0 wz--n- 5.00g 2.00g
$ sudo lvs
  LV      VG   Attr      LSize Pool Origin Data%  Move Log Copy%  Convert
  testlv  test -wi-a---- 1.00g
  testlv2 test -wi-a---- 2.00g

Facts Returned:
$ ansible localhost -i /tmp/inv -m setup -a 'filter=ansible_lvm'
localhost | success >> {
    "ansible_facts": {
        "ansible_lvm": {
            "lvs": {
                "testlv": {
                    "size_g": "1.00",
                    "vg": "test"
                },
                "testlv2": {
                    "size_g": "2.00",
                    "vg": "test"
                }
            },
            "vgs": {
                "test": {
                    "free_g": "2.00",
                    "num_lvs": "2",
                    "num_pvs": "1",
                    "size_g": "5.00"
                }
            }
        }
    },
    "changed": false
}

Test as non-root:
$ ansible localhost -i /tmp/inv-user -m setup -a 'filter=ansible_lvm'
localhost | success >> {
    "ansible_facts": {},
    "changed": false
}

Test without lvm utilities available
$ sudo mv /sbin/vgs{,.bk}
$ ansible localhost -i /tmp/inv -m setup -a 'filter=ansible_lvm'
localhost | success >> {
    "ansible_facts": {},
    "changed": false
}
2015-07-28 07:46:01 +05:30
..
cli A better error message for «ansible playbook.yml» 2015-07-27 12:43:21 +05:30
compat Making the switch to v2 2015-05-03 21:47:26 -05:00
config Making the switch to v2 2015-05-03 21:47:26 -05:00
errors Making the switch to v2 2015-05-03 21:47:26 -05:00
executor Reworking internal result flags and making sure include_vars hides vault data 2015-07-27 14:04:31 -04:00
galaxy Make ansible-galaxy work with galaxy.ansible.com 2015-07-24 16:04:10 -04:00
inventory Further cleanup of internal use of ansible_ssh_host 2015-07-27 10:42:39 -04:00
module_utils Add LVM facts to setup module 2015-07-28 07:46:01 +05:30
modules moved openvz inventory script to new home 2015-07-27 20:53:53 -04:00
new_inventory Making the switch to v2 2015-05-03 21:47:26 -05:00
parsing Encrypt the vault file after editing only if the contents changed 2015-07-26 14:41:34 +05:30
playbook started implementing diff 2015-07-26 12:22:22 -04:00
plugins Additional changes to fix fileglob relative path lookups 2015-07-27 16:35:57 -04:00
template Allowing args: "{{some_var}}" for task params again 2015-07-24 10:33:12 -04:00
utils optimized module docs 2015-07-27 20:52:53 -04:00
vars Fix issues with vars_prompt and vars_files 2015-07-21 14:52:57 -04:00
__init__.py Re-adding submodules after moving things around 2015-05-03 22:30:51 -05:00
constants.py started implementing diff 2015-07-26 12:22:22 -04:00
test-requirements.txt Making the switch to v2 2015-05-03 21:47:26 -05:00