|
39 | 39 |
|
40 | 40 | # Using data exported by terraform in ebs_id_to_device_name, create a |
41 | 41 | # sdX -> nvmeXn1 map, based on the device serial |
| 42 | +- name: Get serial number for each nvme device |
| 43 | + ansible.builtin.command: cat /sys/class/block/{{ item.key }}/device/serial |
| 44 | + register: nvme_serial_list |
| 45 | + loop: "{{ nvme_device_list }}" |
| 46 | + changed_when: false |
| 47 | + when: |
| 48 | + - cloud_platform_is_aws and not aws_machine_type_is_r4 |
| 49 | + |
42 | 50 | - name: Build /dev/sdX to nvme device mapping for attached volumes |
43 | 51 | ansible.builtin.set_fact: |
44 | | - sd_to_nvme_map: "{{ sd_to_nvme_map | default({}) | combine({ device_name: '/dev/' ~ nvme_dev.key }) }}" |
45 | | - loop: "{{ nvme_device_list }}" |
46 | | - loop_control: |
47 | | - loop_var: nvme_dev |
| 52 | + sd_to_nvme_map: "{{ sd_to_nvme_map | default({}) | combine({ device_name: '/dev/' ~ item.item.key }) }}" |
| 53 | + loop: "{{ nvme_serial_list.results }}" |
48 | 54 | vars: |
49 | | - # terraform (aws) exports the serial as "vol-xxx" while the system sees it as "volxxx", so we need to omit the '-' |
50 | | - volume_id: "{{ nvme_dev.value.serial | regex_replace('^vol(?!-)', 'vol-') }}" |
| 55 | + # terraform (aws) exports the serial as "vol-xxx" while the system sees it as "volxxx", so we need to omit the '-'. |
| 56 | + # The regex is constructed to not match on serials that already start with vol- |
| 57 | + volume_id: "{{ item.stdout | regex_replace('^vol(?!-)', 'vol-') }}" |
51 | 58 | device_name: "{{ ebs_id_to_device_name_map.get(volume_id, '') }}" |
52 | 59 | when: |
53 | 60 | - cloud_platform_is_aws and not aws_machine_type_is_r4 |
54 | 61 | - device_name != '' # only map if the serial id exists in the exported serial ids from terraform |
55 | 62 |
|
56 | | -- name: "Adjust PV list for storage profile {{ item.key }}" |
| 63 | +- name: Adjust PV list for storage profile {{ item.key }} |
57 | 64 | ansible.builtin.set_fact: |
58 | 65 | adjusted_pv: >- |
59 | 66 | {{ |
|
69 | 76 | msg: "Using PV list: {{ (adjusted_pv is defined and (adjusted_pv | length) > 0) | ternary(adjusted_pv, item.value.pv) }}" |
70 | 77 |
|
71 | 78 | # Create Volume Group |
72 | | -- name: "SAP Storage Preparation - Volume Group One: {{ [qe_sap_storage_cloud_type | upper, item.value.name] | join(' - ') }}" |
| 79 | +- name: "SAP Storage Preparation - Volume Group One: {{ item.value.name + ' on ' + sap_storage_cloud_type }}" |
73 | 80 | community.general.lvg: |
74 | 81 | vg: "{{ item.value.vg }}" |
75 | 82 | pvs: "{{ (adjusted_pv is defined and (adjusted_pv | length) > 0) | ternary(adjusted_pv, item.value.pv) }}" |
|
85 | 92 | when: adjusted_pv is defined |
86 | 93 |
|
87 | 94 | # Create Logical Group - One |
88 | | -- name: "SAP Storage Preparation - Logical Volume - One: {{ [qe_sap_storage_cloud_type | upper, item.value.name] | join(' - ') }}" |
| 95 | +- name: "SAP Storage Preparation - Logical Volume One: {{ item.value.name + ' on ' + sap_storage_cloud_type }}" |
89 | 96 | community.general.lvol: |
90 | 97 | vg: "{{ item.value.vg }}" |
91 | 98 | lv: "{{ item.value.lv }}" |
|
94 | 101 | - "item.value.numluns == '1'" |
95 | 102 |
|
96 | 103 | # Create Logical Group - Striped |
97 | | -- name: "SAP Storage Preparation - Logical Volume - Striped: {{ [qe_sap_storage_cloud_type | upper, item.value.name] | join(' - ') }}" |
| 104 | +- name: "SAP Storage Preparation - Logical Volume Striped: {{ item.value.name + ' on ' + sap_storage_cloud_type }}" |
98 | 105 | community.general.lvol: |
99 | 106 | vg: "{{ item.value.vg }}" |
100 | 107 | lv: "{{ item.value.lv }}" |
|
104 | 111 | - "item.value.numluns != '1'" |
105 | 112 |
|
106 | 113 | # Create Filesystem |
107 | | -- name: "SAP Storage Preparation - Filesystem: {{ [qe_sap_storage_cloud_type | upper, item.value.name] | join(' - ') }}" |
| 114 | +- name: "SAP Storage Preparation - Filesystem: {{ item.value.name + ' on ' + sap_storage_cloud_type }}" |
108 | 115 | community.general.filesystem: |
109 | 116 | fstype: xfs |
110 | 117 | dev: "/dev/{{ item.value.vg }}/{{ item.value.lv }}" |
111 | 118 |
|
112 | 119 | # Mount Filesystem |
113 | | -- name: "SAP Storage Preparation - Mount: {{ [qe_sap_storage_cloud_type | upper, item.value.name] | join(' - ') }}" |
| 120 | +- name: "SAP Storage Preparation - Mount: {{ item.value.name + ' on ' + sap_storage_cloud_type }}" |
114 | 121 | ansible.posix.mount: |
115 | 122 | path: "{{ item.value.directory }}" |
116 | 123 | fstype: xfs |
|
0 commit comments