Skip to content

Commit 686b826

Browse files
Improvements in Configuration Checks (#133)
1 parent d4d727c commit 686b826

File tree

9 files changed

+1038
-110
lines changed

9 files changed

+1038
-110
lines changed

src/module_utils/filesystem_collector.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -671,12 +671,18 @@ def gather_lvm_groups_info(self, lvm_groups, vg_to_disk_names, azure_disk_data):
671671
total_iops += perf_data.get("iops", 0)
672672
total_mbps += perf_data.get("mbps", 0)
673673

674+
totalsize = vg_data.get("total_size", "")
675+
674676
lvm_groups_info.append(
675677
{
676678
"Name": vg_name,
677679
"Disks": vg_data.get("disks", 0),
678680
"LogicalVolumes": vg_data.get("logical_volumes", 0),
679-
"TotalSize": vg_data.get("total_size", ""),
681+
"TotalSize": (
682+
totalsize.replace("g", "GiB").replace("t", "TiB")
683+
if totalsize and isinstance(totalsize, str)
684+
else totalsize
685+
),
680686
"TotalIOPS": total_iops,
681687
"TotalMBPS": total_mbps,
682688
}
@@ -704,14 +710,20 @@ def gather_lvm_volumes_info(self, lvm_volumes):
704710

705711
try:
706712
for lv_name, lv_data in lvm_volumes.items():
713+
size = lv_data.get("size", "")
714+
707715
lvm_volumes_info.append(
708716
{
709717
"Name": lv_name,
710718
"VGName": lv_data.get("vg_name", ""),
711719
"LVPath": lv_data.get("path", ""),
712720
"DMPath": lv_data.get("dm_path", ""),
713721
"Layout": lv_data.get("layout", ""),
714-
"Size": lv_data.get("size", ""),
722+
"Size": (
723+
size.replace("g", "GiB").replace("t", "TiB")
724+
if size and isinstance(size, str)
725+
else size
726+
),
715727
"StripeSize": lv_data.get("stripe_size", ""),
716728
"Stripes": lv_data.get("stripes", ""),
717729
}

src/playbook_00_configuration_checks.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
| map(attribute='value')
3232
| first }}"
3333

34-
3534
- hosts: "{{ sap_sid | upper }}_SCS:
3635
{{ sap_sid | upper }}_ERS:
3736
{{ sap_sid | upper }}_DB:
@@ -98,6 +97,12 @@
9897
checks_var: "common_sap_checks",
9998
results_var: "common_sap_results"
10099
}
100+
- {
101+
name: "Networking",
102+
file_name: "network",
103+
checks_var: "networking_checks",
104+
results_var: "networking_results"
105+
}
101106
loop_control:
102107
loop_var: check_type
103108

@@ -264,6 +269,23 @@
264269
groups[sap_sid | upper + '_PAS']|default([]) }}"
265270
when: hostvars[item].common_sap_results is defined
266271

272+
- name: "Collect networking check results"
273+
ansible.builtin.set_fact:
274+
all_results: "{{ all_results + hostvars[item].networking_results
275+
| default([]) }}"
276+
execution_metadata: "{{ execution_metadata + [
277+
{'host': item,
278+
'check_type': 'networking',
279+
'metadata': hostvars[item].networking_results_metadata
280+
| default({})}] }}"
281+
loop: "{{ groups[sap_sid | upper + '_SCS']|default([]) +
282+
groups[sap_sid | upper + '_ERS']|default([]) +
283+
groups[sap_sid | upper + '_DB']|default([]) +
284+
groups[sap_sid | upper + '_APP']|default([]) +
285+
groups[sap_sid | upper + '_WEB']|default([]) +
286+
groups[sap_sid | upper + '_PAS']|default([]) }}"
287+
when: hostvars[item].networking_results is defined
288+
267289
- name: "Collect DB (HANA) check results"
268290
ansible.builtin.set_fact:
269291
all_results: "{{ all_results + hostvars[item].db_hana_results

src/roles/configuration_checks/tasks/disks.yml

Lines changed: 62 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,54 @@
9595
az disk show --name {{ item }} \
9696
--subscription {{ compute_metadata.json.compute.subscriptionId }} \
9797
--resource-group {{ compute_metadata.json.compute.resourceGroupName }} \
98-
--query "{name:name, sku:sku.name, size:sizeGb, encryption:encryption.type, iops:diskIOPSReadWrite, mbps:diskMBpsReadWrite, size:diskSizeGB}" --output json
98+
--query "{name:name, sku:sku.name, size:sizeGb, encryption:encryption.type, iops:diskIOPSReadWrite, mbps:diskMBpsReadWrite, size:diskSizeGB, tier:tier}" --output json
9999
100100
- name: Debug azure disks data collected
101101
when: azure_disks_metadata_results is defined
102102
ansible.builtin.debug:
103103
var: azure_disks_metadata_results
104104
verbosity: 1
105105

106+
- name: Check if any NFS filesystem is mounted
107+
ansible.builtin.set_fact:
108+
has_nfs_mounts: "{{ mount_info.stdout_lines | select('search', '\\snfs[34]?\\s') | list | length > 0 }}"
109+
110+
- name: Check for ANF usage in mount_info, looking for IP addresses
111+
when: has_nfs_mounts | bool
112+
ansible.builtin.set_fact:
113+
anf_ip_addresses: "{{ mount_info.stdout_lines
114+
| map('split', ' ')
115+
| map('list')
116+
| selectattr('1', 'defined')
117+
| map(attribute='1')
118+
| select('match', '^(\\d{1,3}\\.){3}\\d{1,3}:')
119+
| map('regex_replace', '^((\\d{1,3}\\.){3}\\d{1,3}):.*', '\\1')
120+
| list
121+
| unique }}"
122+
- name: Debug ANF IP addresses found
123+
when: anf_ip_addresses is defined
124+
ansible.builtin.debug:
125+
var: anf_ip_addresses
126+
127+
- name: Check for AFS usage in mount_info, looking for storage account names
128+
when: has_nfs_mounts | bool
129+
ansible.builtin.set_fact:
130+
afs_storage_accounts: "{{ mount_info.stdout_lines
131+
| map('split', ' ')
132+
| map(attribute='1')
133+
| select('search', '\\.file\\.core\\.windows\\.net:/')
134+
| map('regex_replace', '^.*:/([^/]+)/.*', '\\1')
135+
| list
136+
| unique }}"
137+
138+
- name: Debug AFS storage account names found
139+
when: afs_storage_accounts is defined
140+
ansible.builtin.debug:
141+
var: afs_storage_accounts
142+
106143
- name: Collect ANF storage data if NFS is used
107144
when:
145+
- has_nfs_mounts | bool
108146
- NFS_provider is defined
109147
- "'ANF' in NFS_provider"
110148
- ANF_account_rg is defined
@@ -155,29 +193,37 @@
155193

156194
- name: Collect AFS storage data if NFS is used
157195
when:
196+
- has_nfs_mounts | bool
158197
- NFS_provider is defined
159198
- "'AFS' in NFS_provider"
199+
- afs_storage_accounts is defined
200+
- afs_storage_accounts | length > 0
160201
register: afs_storage_metadata_results
161202
delegate_to: localhost
162203
ansible.builtin.shell:
163204
executable: /bin/bash
164205
cmd: |
165206
set -o pipefail
166-
for sa in $(az storage account list \
167-
--query "[?kind=='FileStorage'].{rg:resourceGroup,name:name,id:id}" \
168-
-o tsv | awk '{print $1":"$2":"$3}'); do rg=$(echo $sa | cut -d: -f1); \
169-
acc=$(echo $sa | cut -d: -f2); sid=$(echo $sa | cut -d: -f3); \
170-
dns="$acc.file.core.windows.net"; for sh in $(az storage share-rm list --resource-group $rg --storage-account $acc \
171-
--query "[?enabledProtocols=='NFS'].[name,accessTier,quotaGiB]" -o tsv); \
172-
do name=$(echo $sh | awk '{print $1}'); tier=$(echo $sh | awk '{print $2}'); \
173-
quota=$(echo $sh | awk '{print $3}'); \
174-
peip=$(az network private-endpoint list \
175-
--query "[?privateLinkServiceConnections[?privateLinkServiceId=='$sid']].customDnsConfigs[].ipAddresses[]" -o tsv); \
176-
for ip in $peip; do thr=$((100 + ( (quota*4+99)/100 ) + ( (quota*6+99)/100 ) )); \
177-
iops=$((quota+3000)); \
178-
if [ $iops -gt 100000 ]; then iops=100000; fi; \
179-
echo "{\"Type\":\"AFS\",\"Name\":\"$name\",\"Pool\":\"$acc\",\"ServiceLevel\":\"$tier\",\"ThroughputMibps\":$thr,\"ProtocolTypes\":\"NFS4.1\",\"NFSAddressDNS\":\"$dns:/$acc/$name\",\"NFSAddress\":\"$ip:/$acc/$name\",\"QoSType\":\"Manual\",\"IOPS\":$iops,\"Id\":\"$sid\"}"; \
180-
done; done; done
207+
for acc in {{ afs_storage_accounts | join(' ') }}; do
208+
sa_info=$(az storage account show --name "$acc" --query "{rg:resourceGroup,name:name,id:id}" -o tsv)
209+
rg=$(echo "$sa_info" | awk '{print $1}')
210+
sid=$(echo "$sa_info" | awk '{print $3}')
211+
dns="$acc.file.core.windows.net"
212+
for sh in $(az storage share-rm list --resource-group "$rg" --storage-account "$acc" \
213+
--query "[?enabledProtocols=='NFS'].[name,accessTier,quotaGiB]" -o tsv); do
214+
name=$(echo "$sh" | awk '{print $1}')
215+
tier=$(echo "$sh" | awk '{print $2}')
216+
quota=$(echo "$sh" | awk '{print $3}')
217+
peip=$(az network private-endpoint list \
218+
--query "[?privateLinkServiceConnections[?privateLinkServiceId=='$sid']].customDnsConfigs[].ipAddresses[]" -o tsv)
219+
for ip in $peip; do
220+
thr=$((100 + ( (quota*4+99)/100 ) + ( (quota*6+99)/100 ) ))
221+
iops=$((quota+3000))
222+
if [ $iops -gt 100000 ]; then iops=100000; fi
223+
echo "{\"Type\":\"AFS\",\"Name\":\"$name\",\"Pool\":\"$acc\",\"ServiceLevel\":\"$tier\",\"ThroughputMibps\":$thr,\"ProtocolTypes\":\"NFS4.1\",\"NFSAddressDNS\":\"$dns:/$acc/$name\",\"NFSAddress\":\"$ip:/$acc/$name\",\"QoSType\":\"Manual\",\"IOPS\":$iops,\"Id\":\"$sid\"}"
224+
done
225+
done
226+
done
181227
182228
- name: Debug AFS storage data collected
183229
when: afs_storage_metadata_results is defined

0 commit comments

Comments
 (0)