Skip to content

Instantly share code, notes, and snippets.

@omaciel
Last active August 29, 2015 14:04
Show Gist options
  • Save omaciel/adedecb1caca546c38cd to your computer and use it in GitHub Desktop.
Save omaciel/adedecb1caca546c38cd to your computer and use it in GitHub Desktop.
Configure Satellite to connect to a proxy
# Block non-proxy traffic from your katello server
# The following environment variables must be set:
# SQUID: the FQDN for your proxy
# PROXY_USERNAME: username for squid
# PROXY_PASSWORD: password for your squid username
export ETH=$(ping -c 1 $(hostname) | grep 'icmp_seq' | awk -F '(' '{print $2}' | awk -F ')' '{print $1}')
export PROXY=$(ping -c 1 $SQUID | grep 'icmp_seq' | awk -F '(' '{print $2}' | awk -F ')' '{print $1}')
echo "# Satellite 6 IP"
iptables -I OUTPUT -d ${ETH} -j ACCEPT
echo "# PROXY IP"
iptables -I OUTPUT -d ${PROXY} -j ACCEPT
echo "# Nameservers"
for entry in $(cat /etc/resolv.conf | grep nameserver | cut -d ' ' -f 2}; do iptables -I OUTPUT -d ${entry} -j ACCEPT; done
iptables-save > /etc/sysconfig/iptables
service iptables restart
# Configuring yum to use the proxy
echo "proxy=http://$PROXY:8888" >> /etc/yum.conf
echo "proxy_username=$PROXY_USERNAME" >> /etc/yum.conf
echo "proxy_password=$PROXY_PASSWORD" >> /etc/yum.conf
# Configuring rhsm to use the proxy
sed -i -e "s/^proxy_hostname.*/proxy_hostname = $PROXY/" /etc/rhsm/rhsm.conf
sed -i -e "s/^proxy_port.*/proxy_port = 8888/" /etc/rhsm/rhsm.conf
sed -i -e "s/^proxy_user.*/proxy_user = $PROXY_USERNAME/" /etc/rhsm/rhsm.conf
sed -i -e "s/^proxy_password.*/proxy_password = $PROXY_PASSWORD/" /etc/rhsm/rhsm.conf
# Run the installer
katello-installer -v --foreman-admin-password='changeme' --katello-proxy-url=http://$PROXY --katello-proxy-port=8888 --katello-proxy-username=$PROXY_USERNAME --katello-proxy-password=$PROXY_PASSWORD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment