Skip to content

Instantly share code, notes, and snippets.

@tomasbasham
Created May 16, 2022 18:50
Show Gist options
  • Save tomasbasham/38511cca82c1fd8017d882e7d75eff12 to your computer and use it in GitHub Desktop.
Save tomasbasham/38511cca82c1fd8017d882e7d75eff12 to your computer and use it in GitHub Desktop.
Install cloud-init if not present on rhel 8
#!/usr/bin/env bash
set -e
# Ensure the script is running as root
if [[ "$(id -u)" != '0' ]]; then
exec sudo "$BASH_SOURCE" "$@"
fi
# Update the system
echo "===> Updating system"
dnf upgrade -y --refresh
# Check cloud-init is not already installed
if ! commad -v cloud-init &> /dev/null; then
echo "===> Installing cloud-init"
dnf install -y cloud-init
fi
# Make sure cloud-init is invoked when the system next initialises.
cloud-init clean
echo "===> Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment