Initial project commit
This commit is contained in:
66
capture_lv_device_details.yml
Normal file
66
capture_lv_device_details.yml
Normal file
@ -0,0 +1,66 @@
|
||||
---
|
||||
- name: Something
|
||||
hosts: bigboot
|
||||
gather_facts: true
|
||||
|
||||
vars:
|
||||
bigboot_boot_device: /dev/sda
|
||||
|
||||
bigboot_test_var:
|
||||
key1: value1
|
||||
key2: value2
|
||||
key3: nope
|
||||
key4: 12345
|
||||
|
||||
tasks:
|
||||
- name: Capture all logical volume paritions on /boot device
|
||||
ansible.builtin.shell:
|
||||
cmd: |
|
||||
set -o pipefail
|
||||
lsblk -pl -o name,type {{ bigboot_boot_device }} | grep -i lvm
|
||||
executable: /bin/bash
|
||||
changed_when: false
|
||||
failed_when: bigboot_adjacent_lvm['rc'] not in [0, 141]
|
||||
register: bigboot_adjacent_lvm
|
||||
|
||||
- name: Map the device to its mount point if applicable
|
||||
ansible.builtin.set_fact:
|
||||
bigboot_adjacent_lvm_devices: "{{ bigboot_adjacent_lvm_devices | default([]) \
|
||||
| combine({item | split(' ') | first: ansible_facts['mounts'] \
|
||||
| selectattr('device', 'equalto', item | split(' ') | first) \
|
||||
| map(attribute='mount')}) }}"
|
||||
loop: "{{ bigboot_adjacent_lvm['stdout_lines'] }}"
|
||||
|
||||
- name: Debug bigboot_adjacent_lvm_devices
|
||||
ansible.builtin.debug:
|
||||
var: bigboot_adjacent_lvm_devices
|
||||
|
||||
- name: Debug - Capture the device name of the mounted logical volumes
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ item['key'] }} :: {{ item['value'] }}"
|
||||
loop: "{{ bigboot_adjacent_lvm_devices | dict2items }}"
|
||||
|
||||
- name: Debug - logic
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ item['key'] }} :: {{ item['value'] }}"
|
||||
loop: "{{ bigboot_adjacent_lvm_devices | dict2items }}"
|
||||
when: item['value'] | regex_search('/[a-zA-Z]')
|
||||
|
||||
- name: Capture the device name of the mounted logical volumes
|
||||
ansible.builtin.set_fact:
|
||||
bigboot_lvm_mounts: "{{ bigboot_lvm_mounts | default([]) + [item['key']] }}"
|
||||
loop: "{{ bigboot_adjacent_lvm_devices | dict2items }}"
|
||||
when: item['value'] | regex_search('[/a-zA-Z]')
|
||||
|
||||
- name: Debug bigboot_lvm_mounts
|
||||
ansible.builtin.debug:
|
||||
var: bigboot_lvm_mounts
|
||||
|
||||
# - name: Set adjacent LVM device name
|
||||
# ansible.builtin.set_fact:
|
||||
# bigboot_adjacent_lvm_device: "{{ bigboot_lvm_mounts | first }}"
|
||||
|
||||
# - name: Debug bigboot_adjacent_lvm_device
|
||||
# ansible.builtin.debug:
|
||||
# var: bigboot_adjacent_lvm_device
|
||||
|
Reference in New Issue
Block a user