Last active
November 12, 2020 07:14
-
-
Save omaciel/66d4c7fcb43b2f8d0963 to your computer and use it in GitHub Desktop.
Install Satellite 6 on EC2
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 sh | |
# Install Satellite 6 on to an Amazon EC2 instance. Make sure to set the variables | |
# in the head of this script. | |
set -o errexit -o nounset | |
# Default user for EC2 images is "ec2-user", so switch to "root" | |
sudo su - | |
# By default the EC2 instance's hostname matches its internal hostname. The | |
# fields ${public_ip} and ${public_dns} can be found in the EC2 Dashboard page | |
# when you select your instance. | |
readonly public_ip= | |
readonly public_dns= | |
# Red hat username, pool ID and password. | |
readonly rh_username= | |
readonly rh_poolid= | |
readonly rh_password= | |
#------------------------------------------------------------------------------- | |
# Update hostname to use public dns values | |
echo "${public_ip} ${public_dns}" >> /etc/hosts | |
hostname "${public_dns}" | |
# Check which version of RHEL we got | |
if uname -r | grep -q el6; then OS_VERSION=6; else OS_VERSION=7; fi | |
# We need to install a few packages, so let's configure our Red Hat | |
# subscription and enable a repo. | |
subscription-manager register --force --username=${rh_username} --password=${rh_password} | |
subscription-manager subscribe --pool=${rh_poolid} | |
# Disable all existing Red Hat repositories | |
subscription-manager repos --disable "*" | |
# Enable only what we need | |
subscription-manager repos --enable rhel-${OS_VERSION}-server-satellite-6.0-rpms | |
subscription-manager repos --enable rhel-${OS_VERSION}-server-rpms | |
subscription-manager repos --enable rhel-server-rhscl-${OS_VERSION}-rpms | |
# Install and start ntpd | |
yum install -y ntp | |
service ntpd start | |
# Install katello | |
yum install -y katello | |
# Update the iptables rules | |
iptables -I INPUT -m state --state NEW -p tcp --dport 443 -j ACCEPT | |
iptables -I INPUT -m state --state NEW -p tcp --dport 5671 -j ACCEPT | |
iptables -I INPUT -m state --state NEW -p tcp --dport 80 -j ACCEPT | |
iptables -I INPUT -m state --state NEW -p tcp --dport 8140 -j ACCEPT | |
iptables -I INPUT -m state --state NEW -p tcp --dport 9090 -j ACCEPT | |
iptables -I INPUT -m state --state NEW -p tcp --dport 22 -j ACCEPT | |
iptables-save > /etc/sysconfig/iptables | |
service iptables restart | |
# SElinux ON | |
setenforce 1 | |
# Initial configuration with some defaults | |
katello-installer -v -d \ | |
--foreman-admin-password='changeme' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment