Skip to content

Commit

Permalink
Merge pull request #744 from sean-freeman/storage_tb_fix
Browse files Browse the repository at this point in the history
sap_storage_setup: fix for TB disks
  • Loading branch information
sean-freeman authored May 29, 2024
2 parents e5b80bf + dd67676 commit 4cf9c7e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 21 deletions.
2 changes: 1 addition & 1 deletion roles/sap_storage_setup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This Ansible Role has been tested for the following SAP software deployment type

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.

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.
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.

## Requirements

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,31 @@
- name: SAP Storage Setup - Make a list of unused disk devices of the requested sizes
ansible.builtin.set_fact:
available_devices: |
{% set av_disks = [] %}
{% set all_disks = (ansible_devices | dict2items) %}
{% for disk in all_disks %}
{%- for fs in sap_storage_setup_new_mounts_fact %}
{%- set av_disks = [] -%}
{%- set all_disks = (ansible_devices | dict2items) -%}
{%- for disk in all_disks -%}
{%- for fs in sap_storage_setup_new_mounts_fact -%}
{%- if disk.value.size | regex_search('.*TB$') -%}
{%- set disk_size_gb = (((( disk.value.size | replace(' TB','') | float * 1024) /8) | round(0,'ceil') * 8) | int) -%}
{%- else -%}
{%- set disk_size_gb = (disk.value.size | regex_replace('(\.\d+\s*)', '') | replace('GB','') | int) -%}
{%- endif -%}
{%- if not disk.key.startswith('dm-')
and disk.value.links.uuids | length == 0
and disk.value.partitions | length == 0
and fs.disk_size is defined
and (fs.disk_size | string + 'GB') in (disk.value.size | regex_replace('(\.\d+\s*)', '')) %}
{%- set add_to_list = av_disks.append(disk) %}
{%- endif %}
{%- endfor %}
{%- endfor %}
and ((disk_size_gb-8) <= fs.disk_size <= (disk_size_gb+8)) -%}
{%- set add_to_list = av_disks.append(disk) -%}
{%- endif -%}
{%- endfor -%}
{%- endfor -%}
{{ av_disks | items2dict }}
# !!
# If the DISK MATCHING syntax has changed in the above, it must also
# be adjusted in the next task
# be adjusted in the next task.
# As ansible_devices returns only human-readable format, handling
# for TB is provided and default is GB; use of MB and PB will error.
# !!

##########
Expand Down Expand Up @@ -60,16 +67,22 @@
-%}
{%- for dev in av_dev -%}
{%- if (fs.disk_size | string + 'GB') in (dev.value.size | regex_replace('(\.\d+\s*)', ''))
{%- if dev.value.size | regex_search('.*TB$') -%}
{% set disk_size_gb = (((( dev.value.size | replace(' TB','') | float * 1024) /8) | round(0,'ceil') * 8) | int) -%}
{%- else -%}
{% set disk_size_gb = (dev.value.size | regex_replace('(\.\d+\s*)', '') | replace('GB','') | int) -%}
{%- endif -%}
{%- if (disk_size_gb-8) <= fs.disk_size <= (disk_size_gb+8)
and dev.key not in assigned_dev
and dev.value.holders | length == 0
and matching_dev | length < (fs.lvm_lv_stripes | d('1') | int) %}
and matching_dev | length < (fs.lvm_lv_stripes | d('1') | int) -%}
{%- set assigned = assigned_dev.append(dev.key) %}
{%- set add = matching_dev.append('/dev/' + dev.key) %}
{%- set assigned = assigned_dev.append(dev.key) -%}
{%- set add = matching_dev.append('/dev/' + dev.key) -%}
{%- endif -%}
{%- endif %}
{%- endfor %}
{%- endfor -%}
{%- if matching_dev | length > 0 -%}
{%- set extend = device_map.extend([
Expand All @@ -80,10 +93,10 @@
'name': fs.name,
'size': fs.disk_size,
}
]) %}
{%- endif %}
{%- endif %}
{%- endfor %}
]) -%}
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{{ device_map }}
Expand Down

0 comments on commit 4cf9c7e

Please sign in to comment.