Skip to content

Commit 4cf9c7e

Browse files
authored
Merge pull request #744 from sean-freeman/storage_tb_fix
sap_storage_setup: fix for TB disks
2 parents e5b80bf + dd67676 commit 4cf9c7e

File tree

2 files changed

+34
-21
lines changed

2 files changed

+34
-21
lines changed

Diff for: roles/sap_storage_setup/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This Ansible Role has been tested for the following SAP software deployment type
1515

1616
This Ansible Role is agnostic, and will run on any Infrastructure Platform. Only LVM is used for local/block storage, to allow for further expansion if the SAP System requires further storage space in the future.
1717

18-
Please note, while this Ansible Role has protection against overwrite of existing disks and filesystems - sensibile review and care is required for any automation of disk storage. Please review the documentation and samples/examples carefully. It is strongly suggested to initially execute the Ansible Playbook calling this Ansible Role, with `ansible-playbook --check` for Check Mode - this will perform no changes to the host and show which changes would be made.
18+
Please note, while this Ansible Role has protection against overwrite of existing disks and filesystems - sensible review and care is required for any automation of disk storage. Please review the documentation and samples/examples carefully. It is strongly suggested to initially execute the Ansible Playbook calling this Ansible Role, with `ansible-playbook --check` for Check Mode - this will perform no changes to the host and show which changes would be made.
1919

2020
## Requirements
2121

Diff for: roles/sap_storage_setup/tasks/generic_tasks/map_single_disks_to_filesystems.yml

+33-20
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,31 @@
99
- name: SAP Storage Setup - Make a list of unused disk devices of the requested sizes
1010
ansible.builtin.set_fact:
1111
available_devices: |
12-
{% set av_disks = [] %}
13-
{% set all_disks = (ansible_devices | dict2items) %}
14-
{% for disk in all_disks %}
15-
{%- for fs in sap_storage_setup_new_mounts_fact %}
12+
{%- set av_disks = [] -%}
13+
{%- set all_disks = (ansible_devices | dict2items) -%}
14+
{%- for disk in all_disks -%}
15+
{%- for fs in sap_storage_setup_new_mounts_fact -%}
16+
{%- if disk.value.size | regex_search('.*TB$') -%}
17+
{%- set disk_size_gb = (((( disk.value.size | replace(' TB','') | float * 1024) /8) | round(0,'ceil') * 8) | int) -%}
18+
{%- else -%}
19+
{%- set disk_size_gb = (disk.value.size | regex_replace('(\.\d+\s*)', '') | replace('GB','') | int) -%}
20+
{%- endif -%}
1621
{%- if not disk.key.startswith('dm-')
1722
and disk.value.links.uuids | length == 0
1823
and disk.value.partitions | length == 0
1924
and fs.disk_size is defined
20-
and (fs.disk_size | string + 'GB') in (disk.value.size | regex_replace('(\.\d+\s*)', '')) %}
21-
{%- set add_to_list = av_disks.append(disk) %}
22-
{%- endif %}
23-
{%- endfor %}
24-
{%- endfor %}
25+
and ((disk_size_gb-8) <= fs.disk_size <= (disk_size_gb+8)) -%}
26+
{%- set add_to_list = av_disks.append(disk) -%}
27+
{%- endif -%}
28+
{%- endfor -%}
29+
{%- endfor -%}
2530
{{ av_disks | items2dict }}
2631
2732
# !!
2833
# If the DISK MATCHING syntax has changed in the above, it must also
29-
# be adjusted in the next task
34+
# be adjusted in the next task.
35+
# As ansible_devices returns only human-readable format, handling
36+
# for TB is provided and default is GB; use of MB and PB will error.
3037
# !!
3138

3239
##########
@@ -60,16 +67,22 @@
6067
-%}
6168
6269
{%- for dev in av_dev -%}
63-
{%- if (fs.disk_size | string + 'GB') in (dev.value.size | regex_replace('(\.\d+\s*)', ''))
70+
71+
{%- if dev.value.size | regex_search('.*TB$') -%}
72+
{% set disk_size_gb = (((( dev.value.size | replace(' TB','') | float * 1024) /8) | round(0,'ceil') * 8) | int) -%}
73+
{%- else -%}
74+
{% set disk_size_gb = (dev.value.size | regex_replace('(\.\d+\s*)', '') | replace('GB','') | int) -%}
75+
{%- endif -%}
76+
{%- if (disk_size_gb-8) <= fs.disk_size <= (disk_size_gb+8)
6477
and dev.key not in assigned_dev
6578
and dev.value.holders | length == 0
66-
and matching_dev | length < (fs.lvm_lv_stripes | d('1') | int) %}
79+
and matching_dev | length < (fs.lvm_lv_stripes | d('1') | int) -%}
6780
68-
{%- set assigned = assigned_dev.append(dev.key) %}
69-
{%- set add = matching_dev.append('/dev/' + dev.key) %}
81+
{%- set assigned = assigned_dev.append(dev.key) -%}
82+
{%- set add = matching_dev.append('/dev/' + dev.key) -%}
83+
{%- endif -%}
7084
71-
{%- endif %}
72-
{%- endfor %}
85+
{%- endfor -%}
7386
7487
{%- if matching_dev | length > 0 -%}
7588
{%- set extend = device_map.extend([
@@ -80,10 +93,10 @@
8093
'name': fs.name,
8194
'size': fs.disk_size,
8295
}
83-
]) %}
84-
{%- endif %}
85-
{%- endif %}
86-
{%- endfor %}
96+
]) -%}
97+
{%- endif -%}
98+
{%- endif -%}
99+
{%- endfor -%}
87100
{{ device_map }}
88101
89102

0 commit comments

Comments
 (0)