Skip to content

Instantly share code, notes, and snippets.

@omaciel
Created September 24, 2015 18:43
Show Gist options
  • Save omaciel/e52c78d48c520101368a to your computer and use it in GitHub Desktop.
Save omaciel/e52c78d48c520101368a to your computer and use it in GitHub Desktop.
Script to install and configure a Pulp Server onto a RHEL 6/7 x86_64 system.
# Script to install and configure a Pulp Server onto a RHEL 6/7 x86_64 system.
# The official documentation can be found here:
# https://pulp.readthedocs.org/en/latest/user-guide/installation.html
export USER_NAME=""
export USER_PASSWORD=""
export POOLID=""
# Handles system services according to the operating system version
function handle_service {
if [ ${OS_VERSION} = '6' ]; then
service $1 start
chkconfig $1 on
else
systemctl enable $1
systemctl start $1
fi
}
# Prerequisites
# Find out whether the system is RHEL 6 or RHEL 7
if uname -r | grep -q el6; then export OS_VERSION=6; else export OS_VERSION=7; fi
# We need a FQDN that is 'reverse lookable'
ip_addr=$(ping -c 1 $(hostname) | grep 'icmp_seq' | awk -F '(' '{print $2}' | awk -F ')' '{print $1}')
echo "${ip_addr} $(hostname)" >> /etc/hosts
# firewall
iptables -I INPUT -m state --state NEW -p tcp --dport 80 -j ACCEPT # access to repositories served over HTTP
iptables -I INPUT -m state --state NEW -p tcp --dport 443 -j ACCEPT # access to repositories served over HTTPS
iptables -I INPUT -m state --state NEW -p tcp --dport 443 -j ACCEPT # access Pulp APIs
iptables -I INPUT -m state --state NEW -p tcp --dport 5672 -j ACCEPT # consumers to connect to the message bus via HTTP
iptables -I INPUT -m state --state NEW -p tcp --dport 5671 -j ACCEPT # consumers to connect to the message bus via HTTPS
iptables-save > /etc/sysconfig/iptables
handle_service iptables
# If using Beaker system, move the `beaker` repo files from the `/etc/yum.repos.d`
mv /etc/yum.repos.d/beaker-* .
# Register and subscribe the system
subscription-manager register --force --user="${USER_PASSWORD}" --password="${USER_PASSWORD}" --release="${OS_VERSION}Server"
subscription-manager subscribe --pool="${POOLID}"
# Clear the cache
subscription-manager refresh
yum clean all
# Disable everything/anything that may be enabled by Beaker
subscription-manager repos --disable "*"
# Download the appropriate repo definition file from the Pulp repository
wget http://repos.fedorapeople.org/repos/pulp/pulp/rhel-pulp.repo
# Enable required RHEL repositories
subscription-manager repos --enable rhel-${OS_VERSION}-server-rpms --enable rhel-${OS_VERSION}-server-optional-rpms
# For RHEL and CentOS systems, the EPEL repositories are required.
if [ ${OS_VERSION} = '6' ]; then
rpm -Uvh https://dl.fedoraproject.org/pub/epel/${OS_VERSION}/x86_64/e/epel-release-${OS_VERSION}-8.noarch.rpm
else
rpm -Uvh https://dl.fedoraproject.org/pub/epel/${OS_VERSION}/x86_64/e/epel-release-${OS_VERSION}-5.noarch.rpm
# EPEL requires users of RHEL 7.x to enable the `optional` and `extra` repositories
subscription-manager repos --enable rhel-${OS_VERSION}-server-extras-rpms
fi
# You must provide a running MongoDB instance for Pulp to use
yum install -y mongodb-server
handle_service mongod
# You must also provide a message bus for Pulp to use.
yum install -y qpid-cpp-server qpid-cpp-server-store
handle_service qpidd
# Install the Pulp server, task workers, and their dependencies.
yum -y groupinstall pulp-server-qpid
# Edit `/etc/pulp/server.conf` under the `messaging` section to use the FQDN of your system.
# After your changes, you should have something like the following:
# [messaging]
# url: tcp://MYSERVER.example.com:5672
sed -i -e "s|^.*url: tcp.*|url: tcp://$(hostname):5672|" /etc/pulp/server.conf
# Edit `/etc/pulp/server.conf` under the `tasks` section to use the FQDN of your system.
# After your changes, you should have something like the following:
# [tasks]
# broker_url: qpid://MYSERVER.example.com/
sed -i -e "s|^.*broker_url.*|broker_url: qpid://$(hostname)|" /etc/pulp/server.conf
# Initialize Pulp’s database as the `apache` user
sudo -u apache pulp-manage-db
# It is recommended that you configure your web server to refuse SSLv3.0
sed -i -e "s|^SSLProtocol all -SSLv2.*|& -SSLv3|" /etc/httpd/conf.d/ssl.conf
handle_service httpd
# Enable and start pulp workers
handle_service pulp_workers
# Start and enable the Celerybeat process
handle_service pulp_celerybeat
# Lastly, one pulp_resource_manager process must be running in the installation
handle_service pulp_resource_manager
# Test
curl -k -u admin:admin -X POST https://localhost/pulp/api/v2/actions/login/
@peymangoly
Copy link

peymangoly commented Oct 15, 2019

It's not work with centos 7 and centos 8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment