diff --git a/modules/1_bastion/bastion.tf b/modules/1_bastion/bastion.tf index 35a6d4b1d..314ce7686 100644 --- a/modules/1_bastion/bastion.tf +++ b/modules/1_bastion/bastion.tf @@ -222,7 +222,14 @@ else sudo subscription-manager register --org='${var.rhel_subscription_org}' --activationkey='${var.rhel_subscription_activationkey}' --force fi sudo subscription-manager refresh -sudo subscription-manager attach --auto + +RHEL_VERSION=$(grep '^VERSION_ID=' /etc/os-release | cut -d'=' -f2 | tr -d '"' | cut -d'.' -f1) +if [ "$RHEL_VERSION" -lt 10 ]; then + echo "RHEL $FULL_VERSION detected: Attaching subscriptions..." + sudo subscription-manager attach --auto +else + echo "RHEL $FULL_VERSION detected: Skipping 'attach' (SCA active)." +fi EOF ] @@ -364,16 +371,25 @@ resource "null_resource" "setup_nfs_disk" { destination = "/tmp/create_disk_link.sh" } provisioner "remote-exec" { - inline = [ - "sudo rm -rf mkdir ${local.storage_path}; sudo mkdir -p ${local.storage_path}; sudo chmod -R 755 ${local.storage_path}", - "sudo chmod +x /tmp/create_disk_link.sh", + inline = [< /dev/null", - "sudo mount ${local.storage_path}", + sudo sed -i 's/\r//g' /tmp/create_disk_link.sh + sudo /tmp/create_disk_link.sh + sudo mkfs.xfs -d sunit=64,swidth=512 /dev/${local.disk_config.disk_name} + MY_DEV_UUID=$(sudo blkid -o export /dev/${local.disk_config.disk_name} | awk '/UUID/{ print }') + echo \"$MY_DEV_UUID ${local.storage_path} xfs defaults 0 0\" | sudo tee -a /etc/fstab > /dev/null + + RHEL_VERSION=$(grep '^VERSION_ID=' /etc/os-release | cut -d'=' -f2 | tr -d '"' | cut -d'.' -f1) + if [ "$RHEL_VERSION" -lt 10 ]; then + sudo mount ${local.storage_path} + else + systemctl daemon-reload + fi +EOF ] } } diff --git a/modules/1_bastion/templates/create_disk_link.sh b/modules/1_bastion/templates/create_disk_link.sh index b500fe1a1..204c03b2a 100644 --- a/modules/1_bastion/templates/create_disk_link.sh +++ b/modules/1_bastion/templates/create_disk_link.sh @@ -14,7 +14,7 @@ else echo "Disk path is /dev/mapper/mpath*" fi -for device in $(ls -1 $disk_path|egrep -v "[0-9]$"); do +for device in $(ls -1 $disk_path | grep -E -v "[0-9]$"); do if [[ ! -b $device"1" ]]; then # Convert disk size to GB device_size=$(lsblk -b -dn -o SIZE $device | awk '{print $1/1073741824}')