Hey, everyone,
I'm having figuring out how to use with_items (or some variation thereof)
in order to loop over a list of items within another list. What I'm trying
to do is allow a playbook to accept a mountpoint variable/input, and then
find the top-level disk device responsible for that. The trick here is
that, when using LVM, you have to find not just the LV associated with the
mountpoint, but also the SCSI device that holds that LV. For example, if
I'm looking at mountpoint / on one of my Linux hosts, Ansible has the
following facts about that mountpoint:
{
"device": "/dev/mapper/centos-root",
"fstype": "xfs",
"mount": "/",
"options": "rw,seclabel,relatime,attr2,inode64,noquota",
"size_available": 9923756032,
"size_total": 14879293440,
"uuid": "e871816f-a069-44a4-a563-cb80e9b733c2"
},
This tells me the device (/dev/mapper/centos-root), but I want the parent
device, and that info is contained in the ansbile_devices fact:
"sda": {
"holders": [],
"host": "SCSI storage controller: LSI Logic / Symbios Logic
53c1030 PCI-X Fusion-MPT Dual Ultra320 SCSI (rev 01)",
"model": "Virtual disk",
"partitions": {
"sda1": {
"holders": [],
"sectors": "1024000",
"sectorsize": 512,
"size": "500.00 MB",
"start": "2048",
"uuid": "e3e17f87-fc28-46a4-9842-d8844c618946"
},
"sda2": {
"holders": [
"centos-root",
"centos-swap"
],
"sectors": "32528384",
"sectorsize": 512,
"size": "15.51 GB",
"start": "1026048",
"uuid": null
}
},
So, we see that the "holders" sub-element of the "sda2" partition, which is
under the partitions element of "sda", which is a device in ansible_devices
is what actually contains the LV that I'm after. Basically what I want to
be able to do is identify that disk "sda" is what contains this volume
given the mountpoint /. I can't quite figure out how, in a playbook, to
loop through in such a way that I'm looking at each of the entries in
ansible_devices (sda, sdb, sdc), then each of the holders entries there
(empty in the above example), then each of the partitions (sda1, sda2,
sda3, etc.), then each of the holders devices on those partitions, until I
find one or more devices that contain the logical volume associated with
the mount point?
Any ideas?
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/0fac77e8-c75d-4d2d-990e-f06cab387f00%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.