|
|
c505a7 |
From ba8a97039805f488c26b4d857f0137a349359c23 Mon Sep 17 00:00:00 2001
|
|
|
c505a7 |
From: Richard Megginson <rmeggins@redhat.com>
|
|
|
c505a7 |
Date: Mon, 16 May 2022 07:51:43 -0600
|
|
|
c505a7 |
Subject: [PATCH] add support for mount_options (#270)
|
|
|
c505a7 |
|
|
|
c505a7 |
* add support for mount_options
|
|
|
c505a7 |
|
|
|
c505a7 |
When support for argument validation was added, that support did not
|
|
|
c505a7 |
include the `mount_options` parameter. This fix adds back that
|
|
|
c505a7 |
parameter. In addition, the volume module arguments are refactored
|
|
|
c505a7 |
so that the common volume parameters such as `mount_options` can be
|
|
|
c505a7 |
specified in one place.
|
|
|
c505a7 |
|
|
|
c505a7 |
This adds a test for the `mount_options` parameter, and adds
|
|
|
c505a7 |
verification for that parameter.
|
|
|
c505a7 |
|
|
|
c505a7 |
* only checkout mount_options if requested
|
|
|
c505a7 |
|
|
|
c505a7 |
(cherry picked from commit ecf3d04bb704db5c1a095aaef40c2372fd45d4d6)
|
|
|
c505a7 |
---
|
|
|
c505a7 |
library/blivet.py | 78 ++++++++++++++----------------
|
|
|
c505a7 |
tests/test-verify-volume-fstab.yml | 22 ++++++++-
|
|
|
c505a7 |
tests/tests_misc.yml | 3 ++
|
|
|
c505a7 |
3 files changed, 60 insertions(+), 43 deletions(-)
|
|
|
c505a7 |
|
|
|
c505a7 |
diff --git a/library/blivet.py b/library/blivet.py
|
|
|
c505a7 |
index 80575bb..29552fa 100644
|
|
|
c505a7 |
--- a/library/blivet.py
|
|
|
c505a7 |
+++ b/library/blivet.py
|
|
|
c505a7 |
@@ -105,6 +105,7 @@ volumes:
|
|
|
c505a7 |
elements: dict
|
|
|
c505a7 |
'''
|
|
|
c505a7 |
|
|
|
c505a7 |
+import copy
|
|
|
c505a7 |
import logging
|
|
|
c505a7 |
import os
|
|
|
c505a7 |
import traceback
|
|
|
c505a7 |
@@ -1500,6 +1501,39 @@ def activate_swaps(b, pools, volumes):
|
|
|
c505a7 |
|
|
|
c505a7 |
def run_module():
|
|
|
c505a7 |
# available arguments/parameters that a user can pass
|
|
|
c505a7 |
+ common_volume_opts = dict(encryption=dict(type='bool'),
|
|
|
c505a7 |
+ encryption_cipher=dict(type='str'),
|
|
|
c505a7 |
+ encryption_key=dict(type='str'),
|
|
|
c505a7 |
+ encryption_key_size=dict(type='int'),
|
|
|
c505a7 |
+ encryption_luks_version=dict(type='str'),
|
|
|
c505a7 |
+ encryption_password=dict(type='str'),
|
|
|
c505a7 |
+ fs_create_options=dict(type='str'),
|
|
|
c505a7 |
+ fs_label=dict(type='str', default=''),
|
|
|
c505a7 |
+ fs_type=dict(type='str'),
|
|
|
c505a7 |
+ mount_options=dict(type='str'),
|
|
|
c505a7 |
+ mount_point=dict(type='str'),
|
|
|
c505a7 |
+ name=dict(type='str'),
|
|
|
c505a7 |
+ raid_level=dict(type='str'),
|
|
|
c505a7 |
+ size=dict(type='str'),
|
|
|
c505a7 |
+ state=dict(type='str', default='present', choices=['present', 'absent']),
|
|
|
c505a7 |
+ type=dict(type='str'))
|
|
|
c505a7 |
+ volume_opts = copy.deepcopy(common_volume_opts)
|
|
|
c505a7 |
+ volume_opts.update(
|
|
|
c505a7 |
+ dict(disks=dict(type='list'),
|
|
|
c505a7 |
+ raid_device_count=dict(type='int'),
|
|
|
c505a7 |
+ raid_spare_count=dict(type='int'),
|
|
|
c505a7 |
+ raid_metadata_version=dict(type='str')))
|
|
|
c505a7 |
+ pool_volume_opts = copy.deepcopy(common_volume_opts)
|
|
|
c505a7 |
+ pool_volume_opts.update(
|
|
|
c505a7 |
+ dict(cached=dict(type='bool'),
|
|
|
c505a7 |
+ cache_devices=dict(type='list', elements='str', default=list()),
|
|
|
c505a7 |
+ cache_mode=dict(type='str'),
|
|
|
c505a7 |
+ cache_size=dict(type='str'),
|
|
|
c505a7 |
+ compression=dict(type='bool'),
|
|
|
c505a7 |
+ deduplication=dict(type='bool'),
|
|
|
c505a7 |
+ raid_disks=dict(type='list', elements='str', default=list()),
|
|
|
c505a7 |
+ vdo_pool_size=dict(type='str')))
|
|
|
c505a7 |
+
|
|
|
c505a7 |
module_args = dict(
|
|
|
c505a7 |
pools=dict(type='list', elements='dict',
|
|
|
c505a7 |
options=dict(disks=dict(type='list', elements='str', default=list()),
|
|
|
c505a7 |
@@ -1517,49 +1551,9 @@ def run_module():
|
|
|
c505a7 |
state=dict(type='str', default='present', choices=['present', 'absent']),
|
|
|
c505a7 |
type=dict(type='str'),
|
|
|
c505a7 |
volumes=dict(type='list', elements='dict', default=list(),
|
|
|
c505a7 |
- options=dict(cached=dict(type='bool'),
|
|
|
c505a7 |
- cache_devices=dict(type='list', elements='str', default=list()),
|
|
|
c505a7 |
- cache_mode=dict(type='str'),
|
|
|
c505a7 |
- cache_size=dict(type='str'),
|
|
|
c505a7 |
- compression=dict(type='bool'),
|
|
|
c505a7 |
- deduplication=dict(type='bool'),
|
|
|
c505a7 |
- encryption=dict(type='bool'),
|
|
|
c505a7 |
- encryption_cipher=dict(type='str'),
|
|
|
c505a7 |
- encryption_key=dict(type='str'),
|
|
|
c505a7 |
- encryption_key_size=dict(type='int'),
|
|
|
c505a7 |
- encryption_luks_version=dict(type='str'),
|
|
|
c505a7 |
- encryption_password=dict(type='str'),
|
|
|
c505a7 |
- fs_create_options=dict(type='str'),
|
|
|
c505a7 |
- fs_label=dict(type='str', default=''),
|
|
|
c505a7 |
- fs_type=dict(type='str'),
|
|
|
c505a7 |
- mount_point=dict(type='str'),
|
|
|
c505a7 |
- name=dict(type='str'),
|
|
|
c505a7 |
- raid_disks=dict(type='list', elements='str', default=list()),
|
|
|
c505a7 |
- raid_level=dict(type='str'),
|
|
|
c505a7 |
- size=dict(type='str'),
|
|
|
c505a7 |
- state=dict(type='str', default='present', choices=['present', 'absent']),
|
|
|
c505a7 |
- type=dict(type='str'),
|
|
|
c505a7 |
- vdo_pool_size=dict(type='str'))))),
|
|
|
c505a7 |
+ options=pool_volume_opts))),
|
|
|
c505a7 |
volumes=dict(type='list', elements='dict',
|
|
|
c505a7 |
- options=dict(disks=dict(type='list'),
|
|
|
c505a7 |
- encryption=dict(type='bool'),
|
|
|
c505a7 |
- encryption_cipher=dict(type='str'),
|
|
|
c505a7 |
- encryption_key=dict(type='str'),
|
|
|
c505a7 |
- encryption_key_size=dict(type='int'),
|
|
|
c505a7 |
- encryption_luks_version=dict(type='str'),
|
|
|
c505a7 |
- encryption_password=dict(type='str'),
|
|
|
c505a7 |
- fs_create_options=dict(type='str'),
|
|
|
c505a7 |
- fs_label=dict(type='str', default=''),
|
|
|
c505a7 |
- fs_type=dict(type='str'),
|
|
|
c505a7 |
- mount_point=dict(type='str'),
|
|
|
c505a7 |
- name=dict(type='str'),
|
|
|
c505a7 |
- raid_level=dict(type='str'),
|
|
|
c505a7 |
- raid_device_count=dict(type='int'),
|
|
|
c505a7 |
- raid_spare_count=dict(type='int'),
|
|
|
c505a7 |
- raid_metadata_version=dict(type='str'),
|
|
|
c505a7 |
- size=dict(type='str'),
|
|
|
c505a7 |
- state=dict(type='str', default='present', choices=['present', 'absent']),
|
|
|
c505a7 |
- type=dict(type='str'))),
|
|
|
c505a7 |
+ options=volume_opts),
|
|
|
c505a7 |
packages_only=dict(type='bool', required=False, default=False),
|
|
|
c505a7 |
disklabel_type=dict(type='str', required=False, default=None),
|
|
|
c505a7 |
safe_mode=dict(type='bool', required=False, default=True),
|
|
|
c505a7 |
diff --git a/tests/test-verify-volume-fstab.yml b/tests/test-verify-volume-fstab.yml
|
|
|
c505a7 |
index 80d78f0..0091084 100644
|
|
|
c505a7 |
--- a/tests/test-verify-volume-fstab.yml
|
|
|
c505a7 |
+++ b/tests/test-verify-volume-fstab.yml
|
|
|
c505a7 |
@@ -11,6 +11,15 @@
|
|
|
c505a7 |
storage_test_fstab_expected_mount_point_matches: "{{ 1
|
|
|
c505a7 |
if (_storage_test_volume_present and storage_test_volume.mount_point and storage_test_volume.mount_point.startswith('/'))
|
|
|
c505a7 |
else 0 }}"
|
|
|
c505a7 |
+ storage_test_fstab_mount_options_matches: "{{ storage_test_fstab.stdout_lines |
|
|
|
c505a7 |
+ map('regex_search', ' ' + storage_test_volume.mount_point + ' .* ' + storage_test_volume.mount_options + ' +') |
|
|
|
c505a7 |
+ select('string')|list if (
|
|
|
c505a7 |
+ storage_test_volume.mount_options|d('none',true) != 'none'
|
|
|
c505a7 |
+ and storage_test_volume.mount_point|d('none',true) != 'none'
|
|
|
c505a7 |
+ ) else [] }}"
|
|
|
c505a7 |
+ storage_test_fstab_expected_mount_options_matches: "{{ 1
|
|
|
c505a7 |
+ if (_storage_test_volume_present and storage_test_volume.mount_options)
|
|
|
c505a7 |
+ else 0 }}"
|
|
|
c505a7 |
|
|
|
c505a7 |
# device id
|
|
|
c505a7 |
- name: Verify that the device identifier appears in /etc/fstab
|
|
|
c505a7 |
@@ -26,7 +35,16 @@
|
|
|
c505a7 |
msg: "Expected number ({{ storage_test_fstab_expected_mount_point_matches }}) of
|
|
|
c505a7 |
entries with volume '{{ storage_test_volume.name }}' mount point not found in /etc/fstab."
|
|
|
c505a7 |
|
|
|
c505a7 |
-# todo: options
|
|
|
c505a7 |
+# mount options
|
|
|
c505a7 |
+- name: Verify mount_options
|
|
|
c505a7 |
+ assert:
|
|
|
c505a7 |
+ that: storage_test_fstab_mount_options_matches|length == storage_test_fstab_expected_mount_options_matches|int
|
|
|
c505a7 |
+ msg: "Expected number ({{ storage_test_fstab_expected_mount_options_matches }}) of
|
|
|
c505a7 |
+ entries with volume '{{ storage_test_volume.name }}' mount options not found in /etc/fstab."
|
|
|
c505a7 |
+ when:
|
|
|
c505a7 |
+ - __storage_verify_mount_options | d(false)
|
|
|
c505a7 |
+ - "'mount_options' in storage_test_volume"
|
|
|
c505a7 |
+ - "'mount_point' in storage_test_volume"
|
|
|
c505a7 |
|
|
|
c505a7 |
- name: Clean up variables
|
|
|
c505a7 |
set_fact:
|
|
|
c505a7 |
@@ -34,3 +52,5 @@
|
|
|
c505a7 |
storage_test_fstab_mount_point_matches: null
|
|
|
c505a7 |
storage_test_fstab_expected_id_matches: null
|
|
|
c505a7 |
storage_test_fstab_expected_mount_point_matches: null
|
|
|
c505a7 |
+ storage_test_fstab_mount_options_matches: null
|
|
|
c505a7 |
+ storage_test_fstab_expected_mount_options_matches: null
|
|
|
c505a7 |
diff --git a/tests/tests_misc.yml b/tests/tests_misc.yml
|
|
|
c505a7 |
index 159c959..97c1627 100644
|
|
|
c505a7 |
--- a/tests/tests_misc.yml
|
|
|
c505a7 |
+++ b/tests/tests_misc.yml
|
|
|
c505a7 |
@@ -189,8 +189,11 @@
|
|
|
c505a7 |
fs_type: 'ext4'
|
|
|
c505a7 |
fs_create_options: '-F'
|
|
|
c505a7 |
mount_point: "{{ mount_location }}"
|
|
|
c505a7 |
+ mount_options: rw,noatime,defaults
|
|
|
c505a7 |
|
|
|
c505a7 |
- include_tasks: verify-role-results.yml
|
|
|
c505a7 |
+ vars:
|
|
|
c505a7 |
+ __storage_verify_mount_options: true
|
|
|
c505a7 |
|
|
|
c505a7 |
- name: Remove the disk volume created above
|
|
|
c505a7 |
include_role:
|
|
|
c505a7 |
--
|
|
|
c505a7 |
2.35.3
|
|
|
c505a7 |
|