Last active
May 17, 2022 12:28
-
-
Save tomasbasham/1011337edf88e1ad22e2339c13f8762b to your computer and use it in GitHub Desktop.
Install Puppet agent and cloud-init on RHEL 8 (CentOS, RockyLinux, AlmaLinux)
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[0]:-$0}" "$@" | |
fi | |
try_install() { | |
if ! command -v $1 &> /dev/null; then | |
echo "===> Installing ${1}" | |
dnf install -y $1 | |
fi | |
} | |
# Update the system | |
echo "===> Updating system" | |
dnf upgrade -y --refresh | |
# Install a release package to enable Puppet Platform repositories | |
echo "===> Installing Puppet release packages" | |
dnf install -y https://yum.puppet.com/puppet7-release-el-8.noarch.rpm | |
dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm | |
# Install puppet agent | |
echo "===> Installing Puppet agent" | |
dnf install -y puppet-agent | |
# Install cloud-init if it is not already present | |
try_install cloud-init | |
# Enable the puppet agent to start on next boot | |
systemctl enable puppet | |
# Reset cloud-init | |
cloud-init clean | |
echo "===> Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment