Files
gitlab-mirror/roles/make_lv/molecule/default/verify.yml
2026-03-19 12:16:48 +03:00

66 lines
2.5 KiB
YAML

---
- name: Verify
hosts: all
gather_facts: false
any_errors_fatal: true
vars:
virtual_group: "group"
logical_volume: "volume"
lvm_dev: "/dev/loop0"
fs_type: ext4
storage_mountpoint: "/mnt"
tasks:
- name: Get volume group list
ansible.builtin.shell:
cmd: "set -o pipefail ; pvs | grep {{ lvm_dev }}"
executable: /bin/bash
changed_when: false
failed_when: false
register: vg_list
- name: Assert that volume group exists
ansible.builtin.assert:
that: virtual_group in vg_list.stdout
success_msg: "{{ lvm_dev }} has {{ virtual_group }} group"
fail_msg: "{{ lvm_dev }} DOES NOT have {{ virtual_group }} group"
- name: Get logical volume list
ansible.builtin.shell:
cmd: "set -o pipefail ; lvs | grep {{ virtual_group }} | grep {{ logical_volume }}"
executable: /bin/bash
changed_when: false
failed_when: false
register: lv_list
- name: Assert that logical volume exists
ansible.builtin.assert:
that: logical_volume in lv_list.stdout
success_msg: "{{ virtual_group }} has {{ logical_volume }} volume"
fail_msg: "{{ virtual_group }} DOES NOT have {{ logical_volume }} volume"
- name: Get filesystem type
ansible.builtin.command: "blkid /dev/mapper/{{ virtual_group }}-{{ logical_volume }} -o value -s TYPE"
changed_when: false
failed_when: false
register: current_fs
- name: Assert that current filesystem is the required one
ansible.builtin.assert:
that: current_fs.stdout == fs_type
success_msg: "{{ virtual_group }} - {{ logical_volume }} has {{ fs_type }} filesystem"
fail_msg: "{{ virtual_group }} - {{ logical_volume }} DOES NOT have {{ fs_type }} filesystem"
- name: Get logical volume mount info # noqa: command-instead-of-module — tells ansible-lint to ignore the error, because you can't actually
# do it with ansible.builtin.mount as the linter begs me to do
ansible.builtin.shell: "mount | grep -w '{{ virtual_group }}-{{ logical_volume }}'"
register: mount_check
ignore_errors: true
changed_when: false
- name: Assert that volume is mounted
ansible.builtin.assert:
that: mount_check.rc == 0
success_msg: "{{ virtual_group }}-{{ logical_volume }} is mounted at {{ storage_mountpoint }}"
fail_msg: "{{ virtual_group }}-{{ logical_volume }} IS NOT mounted at {{ storage_mountpoint }}"