mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
24aeedbc15
* lvg: add UUID reset, rename, active switch feature * Add changelog fragment for 6682 * Fix Sanity 2.15,devel tests * Fix issue with LVM autoactivation * Remove rename implementation Add active/inactive states Fix errors when a PV is missing Apply suggestions from code review Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/lvg.py Co-authored-by: Felix Fontein <felix@fontein.de> --------- Co-authored-by: Felix Fontein <felix@fontein.de>
153 lines
3.9 KiB
YAML
153 lines
3.9 KiB
YAML
---
|
|
# Copyright (c) Ansible Project
|
|
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
- name: Create volume group on disk device
|
|
lvg:
|
|
vg: testvg
|
|
pvs: "{{ loop_device1 }}"
|
|
|
|
- name: Create logical volumes on volume group
|
|
loop:
|
|
- lv1
|
|
- lv2
|
|
lvol:
|
|
vg: testvg
|
|
lv: "{{ item }}"
|
|
size: 2m
|
|
|
|
- name: Collect all lv active status in testvg
|
|
shell: vgs -olv_active --noheadings testvg | xargs -n1
|
|
register: initial_lv_status_result
|
|
|
|
- name: Assert all lv in testvg are active
|
|
loop: "{{ initial_lv_status_result.stdout_lines }}"
|
|
assert:
|
|
that:
|
|
- "'active' == '{{ item }}'"
|
|
|
|
- name: Deactivate volume group
|
|
lvg:
|
|
state: inactive
|
|
vg: testvg
|
|
register: vg_deactivate_result
|
|
|
|
- name: Collect all lv active status in testvg
|
|
shell: vgs -olv_active --noheadings testvg | xargs -n1
|
|
register: deactivated_lv_status_result
|
|
|
|
- name: Do all assertions to verify expected results
|
|
assert:
|
|
that:
|
|
- vg_deactivate_result is changed
|
|
- "'active' not in deactivated_lv_status_result.stdout"
|
|
|
|
- name: Deactivate volume group again to verify idempotence
|
|
lvg:
|
|
state: inactive
|
|
vg: testvg
|
|
register: repeated_vg_deactivate_result
|
|
|
|
- name: Verify vg deactivation idempontency
|
|
assert:
|
|
that:
|
|
- repeated_vg_deactivate_result is not changed
|
|
|
|
- name: Activate volume group in check mode
|
|
lvg:
|
|
state: active
|
|
vg: testvg
|
|
register: check_mode_vg_activate_result
|
|
check_mode: true
|
|
|
|
- name: Collect all lv active status in testvg
|
|
shell: vgs -olv_active --noheadings testvg | xargs -n1
|
|
register: check_mode_activate_lv_status_result
|
|
|
|
- name: Verify VG activation in check mode changed without activating LVs
|
|
assert:
|
|
that:
|
|
- check_mode_vg_activate_result is changed
|
|
- "'active' not in check_mode_activate_lv_status_result.stdout"
|
|
|
|
- name: Activate volume group
|
|
lvg:
|
|
state: active
|
|
vg: testvg
|
|
register: vg_activate_result
|
|
|
|
- name: Collect all lv active status in testvg
|
|
shell: vgs -olv_active --noheadings testvg | xargs -n1
|
|
register: activate_lv_status_result
|
|
|
|
- name: Verify vg activation
|
|
assert:
|
|
that:
|
|
- vg_activate_result is changed
|
|
|
|
- name: Assert all lv in testvg are active
|
|
loop: "{{ activate_lv_status_result.stdout_lines }}"
|
|
assert:
|
|
that:
|
|
- "'active' == '{{ item }}'"
|
|
|
|
- name: Activate volume group again to verify idempontency
|
|
lvg:
|
|
state: active
|
|
vg: testvg
|
|
register: repeated_vg_activate_result
|
|
|
|
- name: Verify vg activation idempontency
|
|
assert:
|
|
that:
|
|
- repeated_vg_activate_result is not changed
|
|
|
|
- name: Deactivate lv2 in testvg
|
|
lvol:
|
|
vg: testvg
|
|
lv: lv2
|
|
active: false
|
|
|
|
- name: Activate volume group again to verify partially activated vg activation
|
|
lvg:
|
|
state: active
|
|
vg: testvg
|
|
register: partial_vg_activate_result
|
|
|
|
- name: Verify partially activated vg activation
|
|
assert:
|
|
that:
|
|
- partial_vg_activate_result is changed
|
|
|
|
- name: Collect all lv active status in testvg
|
|
shell: vgs -olv_active --noheadings testvg | xargs -n1
|
|
register: activate_partial_lv_status_result
|
|
|
|
- name: Assert all lv in testvg are active
|
|
loop: "{{ activate_partial_lv_status_result.stdout_lines }}"
|
|
assert:
|
|
that:
|
|
- "'active' == '{{ item }}'"
|
|
|
|
- name: Deactive volume group in check mode
|
|
lvg:
|
|
state: inactive
|
|
vg: testvg
|
|
register: check_mode_vg_deactivate_result
|
|
check_mode: true
|
|
|
|
- name: Collect all lv active status in testvg
|
|
shell: vgs -olv_active --noheadings testvg | xargs -n1
|
|
register: check_mode_deactivate_lv_status_result
|
|
|
|
- name: Verify check mode vg deactivation changed
|
|
assert:
|
|
that:
|
|
- check_mode_vg_deactivate_result is changed
|
|
|
|
- name: Assert all lv in testvg are still active
|
|
loop: "{{ check_mode_deactivate_lv_status_result.stdout_lines }}"
|
|
assert:
|
|
that:
|
|
- "'active' == '{{ item }}'"
|