mirror of
https://github.com/mrlesmithjr/ansible-manage-lvm.git
synced 2026-09-06 23:48:12 +03:00
testing singl lv and only vg
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user