Useful pulp workflow commands

These are some scribble notes helpful for understanding and managing pulp, the Redhat repository manager
There are many many more things one can do with pulp (snapshots, non-rpm content, etc), but I'll just stick to the basics here.

Services, start, stop etc

Important: pulp_resource_manager and pulp_celerybeat should only be installed on one system within a pulp workflow environment (then pulp member servers register with the pulp_resource_manager)

Start
systemctl start pulp_celerybeat.service
systemctl start pulp_resource_manager.service
systemctl start pulp_workers.service
systemctl start httpd
systemctl start qpidd
systemctl start goferd
Stop
systemctl stop pulp_celerybeat.service
systemctl stop pulp_resource_manager.service
systemctl stop pulp_workers.service
systemctl stop httpd
systemctl stop qpidd
systemctl stop goferd
Restart
systemctl restart pulp_celerybeat.service
systemctl restart pulp_resource_manager.service
systemctl restart pulp_workers.service
systemctl restart httpd
systemctl restart qpidd
systemctl restart goferd

Log in to pulp-admin

Annoying as this is, pulp requires authentication before you can use the admin commands. If you've made it this far (root on the Pulp server terminal) you're probably OK anyway. LDAP is also an option

pulp-admin login -u admin -p admin

(default credentials are obviously admin/admin)
An administrative session lasts about 1 week (then you need to log in again)

Create a Pulp RPM repo

To create a new pulp repo (i.e. a cached/synced copy of a particular repo), we just need a few short commands.
For this example, we are syncing the epel (Extra Packages for Enterprise Linux) repo, and just serving HTTP. We assume that the Pulp server has direct internet access.

pulp-admin rpm repo create --repo-id=centos7-epel --feed=http://download.fedoraproject.org/pub/epel/7/x86_64 --proxy-host=http://myproxy --proxy-port=8080 --serve-http=true --serve-https=false --relative-url=/pub/epel/7
pulp-admin rpm repo sync run --repo-id=centos7-epel

Then, the repo can be accessed by clients using the following repo definition (e.g. /etc/yum.repos.d/robbie-centos7-epel.repo)

[robbie-centos7-epel]
name=EPEL Repo mirror on Robbie Pulp Server
baseurl=http://pulp.example.com/pulp/repos/pub/epel/7/
enabled=1
gpgcheck=0
priority=1

Modify an existing Pulp RPM repo

If we wanted to perhaps update the relative-url of an existing repo, we could type

pulp-admin rpm repo update --repo-id=centos7-epel --relative-url=/pub/centos-epel/7
pulp-admin rpm repo publish --repo-id=centos7-epel

Add an RPM to the oem/optiver repo

(for this example I'll demonstrate with user 'robbie')

Create/get RPM content

Build the RPM and SRPM on another host or otherwise attain the RPM and SRPM

Copy the RPM and SRPM to pulp
[robbie@workstation rpmbuild]$ scp ./RPMS/x86_64/henry-the-amazing-galloping-elephant-0.1.0-1.el7.centos.x86_64.rpm pulp-server:/home/robbie
henry-the-amazing-galloping-elephant-0.1.0-1.el7.centos.x86_64.rpm                                                                                                                                                       100% 8742KB   4.8MB/s   00:00
[robbie@workstation rpmbuild]$ scp ./SRPMS/henry-the-amazing-galloping-elephant-0.1.0-1.el7.centos.src.rpm opsynxvm0297:/home/robcan
henry-the-amazing-galloping-elephant-0.1.0-1.el7.centos.src.rpm                                                                                                                                                          100% 6133KB   4.4MB/s   00:00
Log into the Pulp host and authenticate with pulp
[robbie@workstation rpmbuild]$ ssh pulp-server

Last login: Wed Nov 31 11:12:13 2016 from 127.0.0.1
[robbie@pulp-server ~]$ sudo pulp-admin login -u admin -p admin
Successfully logged in. Session certificate will expire at Oct 25 23:19:45 2016
GMT.

Upload the files to pulp

The separate upload dir is helpful to ensure the for loop doesn't accidentally submit old RPMs to the Repo, possibly compromising the repo contents with out of date or broken RPMs. Theoretically if RPM versions are incremented correctly it won't matter anyway, but best to play it safe.

[robbie@pulp-server ~]$ rm -rf uploaddir/
[robbie@pulp-server ~]$ mkdir uploaddir
[robbie@pulp-server ~]$ mv henry-the-amazing-galloping-elephant-0.1.0-1.el7.centos.x86_64.rpm uploaddir/
[robbie@pulp-server ~]$ mv henry-the-amazing-galloping-elephant-0.1.0-1.el7.centos.src.rpm uploaddir/
[robbie@pulp-server ~]$ cd uploaddir
[robbie@pulp-server uploaddir]$ for f in *x86_64.rpm *.noarch.rpm ; do sudo pulp-admin rpm repo uploads rpm --repo-id=robbierepo --file=$f ; done; for f in *src.rpm ; do sudo pulp-admin rpm repo uploads srpm --repo-id=robbierepo-source --file=$f ; done
Publish the files
[robbie@pulp-server uploaddir]$ sudo pulp-admin rpm repo publish run --repo-id=robbierepo-source
[robbie@pulp-server uploaddir]$ sudo pulp-admin rpm repo publish run --repo-id=robbierepo
[robbie@pulp-server uploaddir]$ sudo createrepo --update -v /var/lib/pulp/published/yum/http/repos/robbierepo/
[robbie@pulp-server uploaddir]$ sudo createrepo --update -v /var/lib/pulp/published/yum/http/repos/robbierepo-source/
Clean up the uploaddir
[robbie@pulp-server uploaddir]$ rm -f *.rpm