Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/lvm_pv/tasks/creation.yml

raw
1 ---
2 # Copyright (c) Ansible Project
3 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
4 # SPDX-License-Identifier: GPL-3.0-or-later
5
6 - name: Creating a 50MB file for loop device
7 ansible.builtin.command: dd if=/dev/zero of={{ remote_tmp_dir }}/test_lvm_pv.img bs=1M count=50
8 args:
9 creates: "{{ remote_tmp_dir }}/test_lvm_pv.img"
10
11 - name: Creating loop device
12 ansible.builtin.command: losetup -f
13 register: loop_device
14
15 - name: Associating loop device with file
16 ansible.builtin.command: 'losetup {{ loop_device.stdout }} {{ remote_tmp_dir }}/test_lvm_pv.img'
17
18 - name: Creating physical volume
19 community.general.lvm_pv:
20 device: "{{ loop_device.stdout }}"
21 register: result
22
23 - name: Checking physical volume size
24 ansible.builtin.command: pvs --noheadings -o pv_size --units M {{ loop_device.stdout }}
25 register: pv_size_output
26
27 - name: Asserting physical volume was created
28 ansible.builtin.assert:
29 that:
30 - result.changed == true
31 - (pv_size_output.stdout | trim | regex_replace('M', '') | float) > 45
32 - (pv_size_output.stdout | trim | regex_replace('M', '') | float) < 55
33 - "'created' in result.msg"