Skip to content

Instantly share code, notes, and snippets.

@omaciel
Last active June 8, 2016 17:59
Show Gist options
  • Save omaciel/11319054 to your computer and use it in GitHub Desktop.
Save omaciel/11319054 to your computer and use it in GitHub Desktop.
Configure Foreman Smart Proxy with all features baked in
# Figure out what OS version we're running
if uname -r | grep -q el6; then export OS_VERSION=6; else export OS_VERSION=7; fi
# Install libvirt
yum install -y libvirt
if [ $OS_VERSION -eq 6 ]
then
service libvirtd start
chkconfig libvirtd on
else
systemctl enable libvirtd
fi
puppet module install -i /tmp domcleal/katellovirt
echo "Full NAT Forwarding"
cd /tmp/katellovirt/
grep -v virbr manifests/libvirt.pp > tempfile
mv -f tempfile manifests/libvirt.pp
puppet apply -v -e 'include katellovirt' --modulepath /tmp
# Satellite 6.2.0 and up
export FORWARDERS=$(for i in $(cat /etc/resolv.conf |grep nameserver|awk '{print $2}'); do echo --foreman-proxy-dns-forwarders $i;done)
# Satellite 6.1.z
# export FORWARDERS=$(for i in $(cat /etc/resolv.conf |grep nameserver|awk '{print $2}'); do echo --capsule-dns-forwarders $i;done)
export OAUTH_SECRET=$(grep oauth_consumer_secret /etc/foreman/settings.yaml | cut -d ' ' -f 2)
export VIRBR=$(ip addr | grep 'virbr1:' | cut -d ':' -f 2 | tr -d '[[:space:]]')
export DNS_ZONE=$(hostname | cut -d '.' -f 2-)
echo $FORWARDERS
echo $OAUTH_SECRET
echo $VIRBR
echo $DNS_ZONE
# Small fix to get virtual host console to work on ui
sed -i '/^:websockets/ s/^/#/' /etc/foreman/settings.yaml
# Satellite 6.2.0 and up
satellite-installer --scenario satellite -v \
--capsule-puppet="true" \
--foreman-admin-password="changeme" \
--foreman-proxy-dhcp-interface="${VIRBR}" \
--foreman-proxy-dhcp="true" \
--foreman-proxy-dns-interface="${VIRBR}" \
--foreman-proxy-dns-zone="${DNS_ZONE}" \
--foreman-proxy-dns="true" \
--foreman-proxy-puppetca="true" \
--foreman-proxy-register-in-foreman="true" \
--foreman-proxy-tftp-servername=$(hostname) \
--foreman-proxy-tftp="true" \
${FORWARDERS}
--katello-enable-ostree=true
# Satellite 6.1.z
# katello-installer -v \
# $FORWARDERS \
# --capsule-dhcp-interface="$VIRBR" \
# --capsule-dhcp="true" \
# --capsule-dns-interface="$VIRBR" \
# --capsule-dns-zone="$DNS_ZONE" \
# --capsule-dns="true" \
# --capsule-foreman-oauth-secret="$OAUTH_SECRET" \
# --capsule-parent-fqdn=$(hostname) \
# --capsule-puppet="true" \
# --capsule-puppetca="true" \
# --capsule-register-in-foreman="true" \
# --capsule-tftp-servername=$(hostname) \
# --capsule-tftp="true" \
# --foreman-admin-password="changeme"
if [ $OS_VERSION -eq 6 ]
then
service dhcpd restart
service docker restart
service libvirtd restart
else
systemctl restart dhcpd
systemctl restart docker
systemctl restart libvirtd
fi
katello-service restart
# Refresh the default capsule's features
CAPSULE_ID=$(hammer -u admin -p changeme --csv capsule list | cut -d ',' -f 1 | grep -vi 'id')
curl -k -u admin:changeme --header 'Content-Type: application/json' --request PUT https://$(hostname)/api/v2/smart_proxies/${CAPSULE_ID}/refresh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment