mirror of
https://github.com/mrlesmithjr/ansible-manage-lvm.git
synced 2026-09-07 16:08:20 +03:00
testing singl lv and only vg
This commit is contained in:
@@ -26,5 +26,7 @@ before_install:
|
|||||||
script:
|
script:
|
||||||
- |
|
- |
|
||||||
sudo molecule test --scenario-name kvm
|
sudo molecule test --scenario-name kvm
|
||||||
|
sudo molecule test --scenario-name kvmsinglelv
|
||||||
|
sudo molecule test --scenario-name kvmonlyvg
|
||||||
notifications:
|
notifications:
|
||||||
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
filesystem: ext4
|
filesystem: ext4
|
||||||
mount: true
|
mount: true
|
||||||
mntp: "/var/lib/mountpoint"
|
mntp: "/var/lib/mountpoint"
|
||||||
- lvname: my_lv2
|
- lvname: my_lw
|
||||||
size: 20%VG
|
size: 20%VG
|
||||||
opts: "--wipesignatures y"
|
opts: "--wipesignatures y"
|
||||||
mount: true
|
mount: true
|
||||||
|
|||||||
@@ -18,6 +18,13 @@ def test_mylv_logical_volume_is_created(host):
|
|||||||
assert int(cmd.stdout.rstrip()) >= 1
|
assert int(cmd.stdout.rstrip()) >= 1
|
||||||
|
|
||||||
|
|
||||||
|
def test_mylv_logical_volume_is_created(host):
|
||||||
|
command = """sudo lvs -o lv_name my_vg --separator='|' --noheadings \
|
||||||
|
| grep -c 'my_lw'"""
|
||||||
|
cmd = host.run(command)
|
||||||
|
assert int(cmd.stdout.rstrip()) >= 1
|
||||||
|
|
||||||
|
|
||||||
def test_volume_is_mounted(host):
|
def test_volume_is_mounted(host):
|
||||||
host.file("/var/lib/mountpoint").mode == 0o731
|
host.file("/var/lib/mountpoint").mode == 0o731
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
filesystem: ext4
|
filesystem: ext4
|
||||||
mount: true
|
mount: true
|
||||||
mntp: "/var/lib/mountpoint"
|
mntp: "/var/lib/mountpoint"
|
||||||
- lvname: my_lv2
|
- lvname: my_lw
|
||||||
size: 20%VG
|
size: 20%VG
|
||||||
opts: "--wipesignatures y"
|
opts: "--wipesignatures y"
|
||||||
mount: true
|
mount: true
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
- name: Converge
|
||||||
|
hosts: all
|
||||||
|
vars:
|
||||||
|
lvm_groups:
|
||||||
|
- vgname: my_vg
|
||||||
|
disks:
|
||||||
|
- /dev/vdb
|
||||||
|
create: true
|
||||||
|
manage_lvm: true
|
||||||
|
tasks:
|
||||||
|
- name: "Include lvm"
|
||||||
|
include_role:
|
||||||
|
name: "ansible-manage-lvm"
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
---
|
||||||
|
driver:
|
||||||
|
name: vagrant
|
||||||
|
provider:
|
||||||
|
name: libvirt
|
||||||
|
lint: yamllint . && flake8 && ansible-lint
|
||||||
|
platforms:
|
||||||
|
- name: Fedora-Molecule-Volumes-KVM
|
||||||
|
box: fedora/31-cloud-base
|
||||||
|
cpu: 2
|
||||||
|
memory: 2048
|
||||||
|
provider_raw_config_args:
|
||||||
|
- "storage :file, :size => '1G', :device => 'vdb'"
|
||||||
|
provisioner:
|
||||||
|
name: ansible
|
||||||
|
config_options:
|
||||||
|
defaults:
|
||||||
|
forks: 20
|
||||||
|
ssh_connection:
|
||||||
|
pipelining: true
|
||||||
|
ssh_args: -o ControlMaster=auto -o ControlPersist=600s
|
||||||
|
verifier:
|
||||||
|
name: testinfra
|
||||||
|
env:
|
||||||
|
PYTHONWARNINGS: "ignore:.*U.*mode is deprecated:DeprecationWarning"
|
||||||
|
options:
|
||||||
|
v: 1
|
||||||
|
scenario:
|
||||||
|
name: kvm
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
"""PyTest Fixtures."""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
import os
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
def pytest_runtest_setup(item):
|
||||||
|
"""Run tests only when under molecule with testinfra installed."""
|
||||||
|
try:
|
||||||
|
import testinfra
|
||||||
|
except ImportError:
|
||||||
|
pytest.skip("Test requires testinfra", allow_module_level=True)
|
||||||
|
if "MOLECULE_INVENTORY_FILE" in os.environ:
|
||||||
|
pytest.testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||||
|
os.environ["MOLECULE_INVENTORY_FILE"]
|
||||||
|
).get_hosts("all")
|
||||||
|
else:
|
||||||
|
pytest.skip(
|
||||||
|
"Test should run only from inside molecule.",
|
||||||
|
allow_module_level=True
|
||||||
|
)
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
"""Role testing files using testinfra."""
|
||||||
|
|
||||||
|
|
||||||
|
def test_lvm_package_shall_be_installed(host):
|
||||||
|
assert host.package("lvm2").is_installed
|
||||||
|
|
||||||
|
|
||||||
|
def test_non_persistent_volume_group_is_created(host):
|
||||||
|
command = """sudo vgdisplay | grep -c 'my_vg'"""
|
||||||
|
cmd = host.run(command)
|
||||||
|
assert '1' in cmd.stdout
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
- name: Converge
|
||||||
|
hosts: all
|
||||||
|
vars:
|
||||||
|
lvm_groups:
|
||||||
|
- vgname: my_vg
|
||||||
|
disks:
|
||||||
|
- /dev/vdb
|
||||||
|
create: true
|
||||||
|
lvnames:
|
||||||
|
- lvname: my_lv
|
||||||
|
size: 40%VG
|
||||||
|
opts: "--wipesignatures y"
|
||||||
|
create: true
|
||||||
|
filesystem: ext4
|
||||||
|
mount: true
|
||||||
|
mntp: "/var/lib/mountpoint"
|
||||||
|
manage_lvm: true
|
||||||
|
tasks:
|
||||||
|
- name: "Include lvm"
|
||||||
|
include_role:
|
||||||
|
name: "ansible-manage-lvm"
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
---
|
||||||
|
driver:
|
||||||
|
name: vagrant
|
||||||
|
provider:
|
||||||
|
name: libvirt
|
||||||
|
lint: yamllint . && flake8 && ansible-lint
|
||||||
|
platforms:
|
||||||
|
- name: Fedora-Molecule-Volumes-KVM
|
||||||
|
box: fedora/31-cloud-base
|
||||||
|
cpu: 2
|
||||||
|
memory: 2048
|
||||||
|
provider_raw_config_args:
|
||||||
|
- "storage :file, :size => '1G', :device => 'vdb'"
|
||||||
|
provisioner:
|
||||||
|
name: ansible
|
||||||
|
config_options:
|
||||||
|
defaults:
|
||||||
|
forks: 20
|
||||||
|
ssh_connection:
|
||||||
|
pipelining: true
|
||||||
|
ssh_args: -o ControlMaster=auto -o ControlPersist=600s
|
||||||
|
verifier:
|
||||||
|
name: testinfra
|
||||||
|
env:
|
||||||
|
PYTHONWARNINGS: "ignore:.*U.*mode is deprecated:DeprecationWarning"
|
||||||
|
options:
|
||||||
|
v: 1
|
||||||
|
scenario:
|
||||||
|
name: kvm
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
"""PyTest Fixtures."""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
import os
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
def pytest_runtest_setup(item):
|
||||||
|
"""Run tests only when under molecule with testinfra installed."""
|
||||||
|
try:
|
||||||
|
import testinfra
|
||||||
|
except ImportError:
|
||||||
|
pytest.skip("Test requires testinfra", allow_module_level=True)
|
||||||
|
if "MOLECULE_INVENTORY_FILE" in os.environ:
|
||||||
|
pytest.testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||||
|
os.environ["MOLECULE_INVENTORY_FILE"]
|
||||||
|
).get_hosts("all")
|
||||||
|
else:
|
||||||
|
pytest.skip(
|
||||||
|
"Test should run only from inside molecule.",
|
||||||
|
allow_module_level=True
|
||||||
|
)
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
"""Role testing files using testinfra."""
|
||||||
|
|
||||||
|
|
||||||
|
def test_lvm_package_shall_be_installed(host):
|
||||||
|
assert host.package("lvm2").is_installed
|
||||||
|
|
||||||
|
|
||||||
|
def test_non_persistent_volume_group_is_created(host):
|
||||||
|
command = """sudo vgdisplay | grep -c 'my_vg'"""
|
||||||
|
cmd = host.run(command)
|
||||||
|
assert '1' in cmd.stdout
|
||||||
|
|
||||||
|
|
||||||
|
def test_mylv_logical_volume_is_created(host):
|
||||||
|
command = """sudo lvs -o lv_name my_vg --separator='|' --noheadings \
|
||||||
|
| grep -c 'my_lv'"""
|
||||||
|
cmd = host.run(command)
|
||||||
|
assert int(cmd.stdout.rstrip()) >= 1
|
||||||
|
|
||||||
|
|
||||||
|
def test_volume_is_mounted(host):
|
||||||
|
host.file("/var/lib/mountpoint").mode == 0o731
|
||||||
|
|
||||||
|
|
||||||
|
def test_volume2_is_mounted(host):
|
||||||
|
host.file("/var/lib/mountpoint2").mode == 0o731
|
||||||
+1
-1
@@ -41,7 +41,7 @@
|
|||||||
)
|
)
|
||||||
# unable to resize xfs: looks like we've to reference the mountpoint instead of the device
|
# unable to resize xfs: looks like we've to reference the mountpoint instead of the device
|
||||||
|
|
||||||
- name: lvm | check already converted
|
- name: manage_lvm | check already converted
|
||||||
# at least xfs is executed twice if the partition has changed in the meantime
|
# at least xfs is executed twice if the partition has changed in the meantime
|
||||||
# then it tries to recreate the fs on the mounted fs which indeed fails...
|
# then it tries to recreate the fs on the mounted fs which indeed fails...
|
||||||
shell: "xfs_info {{ lv.mntp }} | grep -c 'ftype=1'"
|
shell: "xfs_info {{ lv.mntp }} | grep -c 'ftype=1'"
|
||||||
|
|||||||
Reference in New Issue
Block a user