Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 26 additions & 10 deletions modules/1_bastion/bastion.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
Expand Down Expand Up @@ -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 = [<<EOF
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
# Fix for copying file from Windows OS having CR,
"sudo sed -i 's/\r//g' /tmp/create_disk_link.sh",
"sudo /tmp/create_disk_link.sh",
"sudo mkfs.xfs /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",
"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
]
}
}
2 changes: 1 addition & 1 deletion modules/1_bastion/templates/create_disk_link.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}')
Expand Down