-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for creating and managing LVM cache volumes
- Loading branch information
1 parent
d522b48
commit b3a1d10
Showing
6 changed files
with
186 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
|
||
- name: check cache options | ||
block: | ||
|
||
- name: Get information about the LV | ||
command: "lvs --noheadings --nameprefixes --units=b --nosuffix --unquoted -o name,attr,cache_total_blocks,chunk_size,segtype | ||
{{ storage_test_pool.name }}/{{ storage_test_volume.name }}" | ||
register: lvs | ||
changed_when: false | ||
|
||
- set_fact: | ||
storage_test_lv_segtype: "{{ lvs.stdout|regex_search('LVM2_SEGTYPE=(\\S+)', '\\1') }}" | ||
|
||
- name: check segment type | ||
assert: | ||
that: "{{ storage_test_lv_segtype[0] == 'cache' if storage_test_volume.cached|bool else storage_test_lv_segtype[0] == 'linear' }}" | ||
msg: "Unexpected segtype {{ storage_test_lv_segtype }} for {{ storage_test_volume.name }}" | ||
|
||
- set_fact: | ||
storage_test_lv_cache_size: "{{ lvs.stdout|regex_search('LVM2_CACHE_TOTAL_BLOCKS=([0-9]*) LVM2_CHUNK_SIZE=([0-9]+)', '\\1', '\\2') }}" | ||
when: storage_test_volume.cached|bool | ||
|
||
- name: parse the requested cache size | ||
bsize: | ||
size: "{{ storage_test_volume.cache_size }}" | ||
register: storage_test_requested_cache_size | ||
when: storage_test_volume.cached|bool | ||
|
||
- set_fact: | ||
storage_test_expected_cache_size: "{{ storage_test_requested_cache_size.bytes }}" | ||
when: storage_test_volume.cached|bool | ||
|
||
- name: Check cache size | ||
assert: | ||
that: "{{ (storage_test_expected_cache_size|int - | ||
storage_test_lv_cache_size[0]|int * storage_test_lv_cache_size[1]|int)|abs / storage_test_expected_cache_size|int < 0.01 }}" | ||
msg: Unexpected cache size, expected {{ storage_test_expected_cache_size }}, got {{ storage_test_lv_cache_size[0]|int * storage_test_lv_cache_size[1]|int }} | ||
when: storage_test_volume.cached|bool | ||
|
||
when: storage_test_volume.type == 'lvm' and _storage_test_volume_present |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
--- | ||
- hosts: all | ||
become: true | ||
vars: | ||
storage_safe_mode: false | ||
mount_location1: '/opt/test1' | ||
mount_location2: '/opt/test2' | ||
volume_group_size: '10g' | ||
volume_size: '5g' | ||
cache_size: '4g' | ||
|
||
tasks: | ||
- include_role: | ||
name: linux-system-roles.storage | ||
|
||
- name: Mark tasks to be skipped | ||
set_fact: | ||
storage_skip_checks: | ||
- blivet_available | ||
- packages_installed | ||
- service_facts | ||
|
||
- include_tasks: get_unused_disk.yml | ||
vars: | ||
min_size: "{{ volume_group_size }}" | ||
max_return: 2 | ||
disks_needed: 2 | ||
|
||
- name: Create a cached LVM logical volume under volume group 'foo' | ||
include_role: | ||
name: linux-system-roles.storage | ||
vars: | ||
storage_pools: | ||
- name: foo | ||
disks: "{{ unused_disks }}" | ||
volumes: | ||
- name: test | ||
size: "{{ volume_size }}" | ||
cached: true | ||
cache_size: "{{ cache_size }}" | ||
cache_devices: "{{ [unused_disks[1]] }}" | ||
|
||
- include_tasks: verify-role-results.yml | ||
|
||
- name: Remove (detach) cache from the 'test' LV created above | ||
include_role: | ||
name: linux-system-roles.storage | ||
vars: | ||
storage_pools: | ||
- name: foo | ||
disks: "{{ unused_disks }}" | ||
volumes: | ||
- name: test | ||
size: "{{ volume_size }}" | ||
cached: false | ||
|
||
- include_tasks: verify-role-results.yml | ||
|
||
- name: Clean up | ||
include_role: | ||
name: linux-system-roles.storage | ||
vars: | ||
storage_pools: | ||
- name: foo | ||
disks: "{{ unused_disks }}" | ||
state: "absent" | ||
volumes: | ||
- name: test | ||
size: "{{ volume_size }}" | ||
|
||
- include_tasks: verify-role-results.yml |