Created
May 16, 2022 18:50
-
-
Save tomasbasham/38511cca82c1fd8017d882e7d75eff12 to your computer and use it in GitHub Desktop.
Install cloud-init if not present on rhel 8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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