Skip to content

Instantly share code, notes, and snippets.

@mpoore
Created April 24, 2024 09:05
Show Gist options
  • Save mpoore/7f917bd0e68f7658e7370bc94f078bfa to your computer and use it in GitHub Desktop.
Save mpoore/7f917bd0e68f7658e7370bc94f078bfa to your computer and use it in GitHub Desktop.
Bash script to install the Salt Minion on a RHEL-based OS and enable a systemd timer
#!/bin/bash
# Configure salt-minion
# @author Michael Poore
## Adding salt repository
echo 'Adding salt repository ...'
major_version=$(echo $OS_VERSION | cut -d '.' -f 1)
echo "-- OS major version: $major_version"
rpm --import https://repo.saltproject.io/salt/py3/redhat/$major_version/x86_64/SALT-PROJECT-GPG-PUBKEY-2023.pub &>/dev/null
curl -fsSL https://repo.saltproject.io/salt/py3/redhat/$major_version/x86_64/latest.repo | tee /etc/yum.repos.d/salt.repo &>/dev/null
## Install salt-minion
echo 'Installing salt-minion ...'
dnf install -y -q salt-minion &>/dev/null
## Configure salt-minion
echo '-- Configuring salt-minion ...'
cat << EOF > /usr/lib/systemd/system/salt-minion.timer
[Unit]
Description=Timer for the salt-minion service
[Timer]
OnBootSec=2min
[Install]
WantedBy=timers.target
EOF
systemctl enable salt-minion.timer &>/dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment