Skip to content

Commit

Permalink
Fix IP issues in AlmaLinux (#381)
Browse files Browse the repository at this point in the history
IP configuration kept getting overridden on Alma by cloud init, causing AzNHC to fail. This was working fine during build, but creating a new VM from the image would revert the configuration. Added config to the SKU Customization service to change it on boot.
  • Loading branch information
LiquidPT authored Sep 16, 2024
1 parent da9984f commit d145736
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
5 changes: 2 additions & 3 deletions alma/common/disable_cloudinit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ network: {config: disabled}
EOF

# Remove Hardware Mac Address and DHCP Name
cp /etc/sysconfig/network-scripts/ifcfg-eth0 tempFile
grep -v -E "HWADDR=|DHCP_HOSTNAME=" /etc/sysconfig/network-scripts/ifcfg-eth0 > tempFile
mv tempFile /etc/sysconfig/network-scripts/ifcfg-eth0
sed -i '/^HWADDR=.*$/d' /etc/sysconfig/network-scripts/ifcfg-eth0
sed -i '/^DHCP_HOSTNAME=.*$/d' /etc/sysconfig/network-scripts/ifcfg-eth0
2 changes: 2 additions & 0 deletions common/setup_sku_customizations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ if [ "$GPU" = "NVIDIA" ]; then
cat <<EOF >/usr/sbin/setup_sku_customizations.sh
#!/bin/bash
/opt/azurehpc/customizations/alma_disable_cloudinit.sh
metadata_endpoint="http://169.254.169.254/metadata/instance?api-version=2019-06-04"
vmSize=\$(curl -H Metadata:true \$metadata_endpoint | jq -r ".compute.vmSize")
Expand Down
12 changes: 12 additions & 0 deletions customizations/alma_disable_cloudinit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
set -ex

# TEMP add to fix changed behavior in AlmaLinux 8.7.
# Cloud init keeps reverting the changes /etc/sysconfig/network-scripts/ifcfg-eth0 even though it is disabled
os=$(cat /etc/os-release | awk 'match($0, /^NAME="(.*)"/, result) { print result[1] }')
if [[ $os == "AlmaLinux" ]]
then
# Remove Hardware Mac Address and DHCP Name
sed -i '/^HWADDR=.*$/d' /etc/sysconfig/network-scripts/ifcfg-eth0
sed -i '/^DHCP_HOSTNAME=.*$/d' /etc/sysconfig/network-scripts/ifcfg-eth0
fi
4 changes: 4 additions & 0 deletions tests/test-definitions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ function verify_ib_device_status {
# verify ifconfig
ifconfig | grep "ib[[:digit:]]:\|ibP"
check_exit_code "IB device is configured" "IB device not configured"

#verify hostname -i returns IP address only
hostname -i | grep -E "^([[:digit:]]{1,3}[\.]){3}[[:digit:]]{1,3}$"
check_exit_code "Hostname -i returns IP address" "Hostname -i does not return IP address"
}

function verify_hpcx_installation {
Expand Down

0 comments on commit d145736

Please sign in to comment.