Debian Client Support in Foreman/Katello

Problem:
Register Debian Client to Foreman/Katello
Expected outcome:
Debian Client registered in Foreman/Katello
Foreman and Proxy versions:
Foreman 1.22.0
Foreman and Proxy plugin versions:
Katello 3.12
Other relevant data:
I have created a Debian Stretch Repository inside Foreman, built a Content View , created an Activation Key with this Content View and tried to add a debian 9 System to foreman using https://pypi.org/project/deb-subscription/ with
deb_subscription --fqdn --organization --location --activation_key

This results in the following error:
Traceback (most recent call last):
File “/usr/local/bin/deb_subscription”, line 112, in
entry = ‘deb%shttps://%s/pulp/deb/%s/%s/%s/%s/%s/%s %s %s\n’ % (trusted, KatelloBase.fqdn, org, environment_name, content_view_name, repository[‘product_type’], repository[‘product’][‘name’], repository[‘name’], release, components)
KeyError: ‘product_type’

Is there any other recommended way to register Debian Clients to Foreman ?
How far is debian supported by foreman anyway ?


logs

Never tried deb-subscription. You should use https://github.com/candlepin/subscription-manager
In this repository, the debian pkgs build instructions are available under contrib/debian.

Is there anyone who successfully built the deb package from source?
I cant find the build instructions in the repo. The commit says " Adding debian / ubuntu package build instructions", but I cannot find those instructions in his commit or the whole repo.

I tried to build it, but tbh, I am not very familiar with building deb packages.

dpkg-buildpackage -us -uc

dpkg-buildpackage: info: source package subscription-manager
dpkg-buildpackage: info: source version 1.25.1-2
dpkg-buildpackage: info: source distribution unstable
dpkg-buildpackage: info: source changed by Bernhard Suttner <suttner@atix.de>
dpkg-buildpackage: info: host architecture amd64
 dpkg-source --before-build contrib
dpkg-source: info: using options from contrib/debian/source/options: --extend-diff-ignore=^[^/]*[.]egg-info/
 debian/rules clean
dh clean --with python2 --buildsystem=pybuild
   debian/rules override_dh_auto_clean
make[1]: Entering directory '/root/subscription-manager/contrib'
dh_auto_clean
	pybuild --clean -i python{version} -p 2.7
W: pybuild base:249: missing command (plugin=custom, method=clean, interpreter=python2.7, version=2.7)
	rm -rf .pybuild/
	find . -name \*.pyc -exec rm {} \;
rm -rf build
rm -rf *.egg-info
make[1]: Leaving directory '/root/subscription-manager/contrib'
   dh_clean -O--buildsystem=pybuild
	rm -f debian/debhelper-build-stamp
	rm -rf debian/.debhelper/
	rm -f debian/apt-transport-katello.debhelper.log debian/katello-upload-profile.debhelper.log debian/python-subscription-manager-doc.debhelper.log debian/python-subscription-manager.debhelper.log
	rm -f -- debian/python-subscription-manager.substvars debian/python-subscription-manager-doc.substvars debian/apt-transport-katello.substvars debian/katello-upload-profile.substvars debian/files
	rm -fr -- debian/python-subscription-manager/ debian/tmp/ debian/python-subscription-manager-doc/ debian/apt-transport-katello/ debian/katello-upload-profile/
	find .  \( \( \
		\( -path .\*/.git -o -path .\*/.svn -o -path .\*/.bzr -o -path .\*/.hg -o -path .\*/CVS -o -path .\*/.pc -o -path .\*/_darcs \) -prune -o -type f -a \
	        \( -name '#*#' -o -name '.*~' -o -name '*~' -o -name DEADJOE \
		 -o -name '*.orig' -o -name '*.rej' -o -name '*.bak' \
		 -o -name '.*.orig' -o -name .*.rej -o -name '.SUMS' \
		 -o -name TAGS -o \( -path '*/.deps/*' -a -name '*.P' \) \
		\) -exec rm -f {} + \) -o \
		\( -type d -a -name autom4te.cache -prune -exec rm -rf {} + \) \)
 dpkg-source -b contrib
dpkg-source: info: using options from contrib/debian/source/options: --extend-diff-ignore=^[^/]*[.]egg-info/
dpkg-source: error: can't build with source format '3.0 (quilt)': no upstream tarball found at ../subscription-manager_1.25.1.orig.tar.{bz2,gz,lzma,xz}
dpkg-buildpackage: error: dpkg-source -b contrib subprocess returned exit status 255

dpkg-buildpackage -rfakeroot -b -uc

dpkg-buildpackage: warning: using a gain-root-command while being root
dpkg-buildpackage: info: source package subscription-manager
dpkg-buildpackage: info: source version 1.25.1-2
dpkg-buildpackage: info: source distribution unstable
dpkg-buildpackage: info: source changed by Bernhard Suttner <suttner@atix.de>
dpkg-buildpackage: info: host architecture amd64
 dpkg-source --before-build contrib
dpkg-source: info: using options from contrib/debian/source/options: --extend-diff-ignore=^[^/]*[.]egg-info/
 fakeroot debian/rules clean
dh clean --with python2 --buildsystem=pybuild
   debian/rules override_dh_auto_clean
make[1]: Entering directory '/root/subscription-manager/contrib'
dh_auto_clean
	pybuild --clean -i python{version} -p 2.7
W: pybuild base:249: missing command (plugin=custom, method=clean, interpreter=python2.7, version=2.7)
	rm -rf .pybuild/
	find . -name \*.pyc -exec rm {} \;
rm -rf build
rm -rf *.egg-info
make[1]: Leaving directory '/root/subscription-manager/contrib'
   dh_clean -O--buildsystem=pybuild
	rm -f debian/debhelper-build-stamp
	rm -rf debian/.debhelper/
	rm -f debian/apt-transport-katello.debhelper.log debian/katello-upload-profile.debhelper.log debian/python-subscription-manager-doc.debhelper.log debian/python-subscription-manager.debhelper.log
	rm -f -- debian/python-subscription-manager.substvars debian/python-subscription-manager-doc.substvars debian/apt-transport-katello.substvars debian/katello-upload-profile.substvars debian/files
	rm -fr -- debian/python-subscription-manager/ debian/tmp/ debian/python-subscription-manager-doc/ debian/apt-transport-katello/ debian/katello-upload-profile/
	find .  \( \( \
		\( -path .\*/.git -o -path .\*/.svn -o -path .\*/.bzr -o -path .\*/.hg -o -path .\*/CVS -o -path .\*/.pc -o -path .\*/_darcs \) -prune -o -type f -a \
	        \( -name '#*#' -o -name '.*~' -o -name '*~' -o -name DEADJOE \
		 -o -name '*.orig' -o -name '*.rej' -o -name '*.bak' \
		 -o -name '.*.orig' -o -name .*.rej -o -name '.SUMS' \
		 -o -name TAGS -o \( -path '*/.deps/*' -a -name '*.P' \) \
		\) -exec rm -f {} + \) -o \
		\( -type d -a -name autom4te.cache -prune -exec rm -rf {} + \) \)
 debian/rules build
dh build --with python2 --buildsystem=pybuild
   dh_update_autotools_config -O--buildsystem=pybuild
   dh_auto_configure -O--buildsystem=pybuild
	pybuild --configure -i python{version} -p 2.7
W: pybuild base:249: missing command (plugin=custom, method=configure, interpreter=python2.7, version=2.7)
   debian/rules override_dh_auto_build
make[1]: Entering directory '/root/subscription-manager/contrib'
make -f Makefile GTK_VERSION=2 OS_DIST=debian PREFIX=/usr
make[2]: Entering directory '/root/subscription-manager/contrib'
make[2]: Makefile: No such file or directory
make[2]: *** No rule to make target 'Makefile'.  Stop.
make[2]: Leaving directory '/root/subscription-manager/contrib'
debian/rules:21: recipe for target 'override_dh_auto_build' failed
make[1]: *** [override_dh_auto_build] Error 2
make[1]: Leaving directory '/root/subscription-manager/contrib'
debian/rules:12: recipe for target 'build' failed
make: *** [build] Error 2
dpkg-buildpackage: error: debian/rules build subprocess returned exit status 2

I buiilt it from source last week on Xenial. I didn’t document it exactly but here were the rough steps I used.

I have no idea if these steps are right but the package was built and seems functional.

git clone

Install build tools
apt install build-essential fakeroot devscripts equivs lintian dpatch quilt

Install build dependencies
apt install debhelper dh-python libglib2.0-dev libdbus-glib-1-dev libgtk2.0-dev libglib2.0-dev libgconf2-dev libnotify-dev lsb-release pkg-config python-all python-setuptools intltool python-dbus python-kitchen python-flake8 python-freezegun python-polib python-coverage python-dev

cd into the source tree

mv contrib/debian …
(move the debian dir up one level in the source tree)

debuild -b -uc -us

FYI - I ran into an issue after I built it where the rhsm.sources file doesn’t seem to use the subscription info to populate the Suites and Components components field correctly. So this means you can subscribe a system and get a sources file built but you’ll get 404 errors when it actually tries to hit the pulp repos. I posted about that in another thread but I think I’m going to need the ATIX guys to chime in to help with that one.

Ahh - I think I ran into the issue you’re seeing. There was a hardcoded path in a sed replacement. I think it was in the debian/rules file. I had to replace lib64 with lib or vice versa.

Thanks for the infos. You helped me to get a bit closer to the finish line :wink:

One thing I didnt do was moving /contrib/debian to the root path.
Afterwards I could step a bit further, but I had a lot problem regarding openssl during compiling.
After installing libssl-dev, those errors were also fixed.

But now I am running into the following error:

copying build/dbus/systemd/rhsm-facts.service -> debian/python-subscription-manager/usr/lib/systemd/system
running install_egg_info
running egg_info
creating subscription_manager.egg-info
writing requirements to subscription_manager.egg-info/requires.txt
writing subscription_manager.egg-info/PKG-INFO
writing top-level names to subscription_manager.egg-info/top_level.txt
writing dependency_links to subscription_manager.egg-info/dependency_links.txt
writing entry points to subscription_manager.egg-info/entry_points.txt
writing manifest file 'subscription_manager.egg-info/SOURCES.txt'
reading manifest file 'subscription_manager.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'subscription_manager.egg-info/SOURCES.txt'
Copying subscription_manager.egg-info to debian/python-subscription-manager/usr/lib/python2.7/site-packages/subscription_manager-1.26.2-py2.7.egg-info
running install_scripts
Installing rhsmd script to debian/python-subscription-manager/usr/bin
Installing rct script to debian/python-subscription-manager/usr/bin
Installing rhsm-facts-service script to debian/python-subscription-manager/usr/bin
Installing rhsm-service script to debian/python-subscription-manager/usr/bin
Installing subscription-manager script to debian/python-subscription-manager/usr/bin
Installing rhsm-debug script to debian/python-subscription-manager/usr/bin
Installing rhn-migrate-classic-to-rhsm script to debian/python-subscription-manager/usr/bin
Installing rhsmcertd-worker script to debian/python-subscription-manager/usr/bin
Installing subscription-manager-gui script to debian/python-subscription-manager/usr/bin
mkdir -p debian/python-subscription-manager//usr/sbin/
mkdir -p debian/python-subscription-manager//
mv debian/python-subscription-manager//usr/bin/subscription-manager debian/python-subscription-manager//usr/sbin/
mv debian/python-subscription-manager//usr/bin/rhn-migrate-classic-to-rhsm debian/python-subscription-manager//usr/sbin/
mv debian/python-subscription-manager//usr/bin/rhsmcertd-worker debian/python-subscription-manager//
mv debian/python-subscription-manager//usr/bin/rhsm-service debian/python-subscription-manager//
mv debian/python-subscription-manager//usr/bin/rhsm-facts-service debian/python-subscription-manager//
mv debian/python-subscription-manager//usr/bin/rhsmd debian/python-subscription-manager//
if [[ "true" == "true" ]]; then \
	mv debian/python-subscription-manager//usr/bin/subscription-manager-gui debian/python-subscription-manager//usr/sbin/; \
else \
	rm debian/python-subscription-manager//usr/bin/subscription-manager-gui; \
fi; \
if [[ "0" = "1" ]]; then \
	mv debian/python-subscription-manager//usr/bin/syspurpose debian/python-subscription-manager//usr/sbin/; \
fi;
find debian/python-subscription-manager//usr/lib64/python2.7/site-packages -name requires.txt -exec sed -i '/dbus-python/d' {} \;
find: ‘debian/python-subscription-manager//usr/lib64/python2.7/site-packages’: No such file or directory
Makefile:313: recipe for target 'install-via-setup' failed
make[2]: *** [install-via-setup] Error 1
make[2]: Leaving directory '/root/subscription-manager'
debian/rules:24: recipe for target 'override_dh_auto_install' failed
make[1]: *** [override_dh_auto_install] Error 2
make[1]: Leaving directory '/root/subscription-manager'
debian/rules:12: recipe for target 'binary-indep' failed
make: *** [binary-indep] Error 2
dpkg-buildpackage: error: debian/rules binary-indep subprocess returned exit status 2

I think this is the same problem you had in the past. ... /usr/lib64/python2.7/site-packages’: No such file or directory

Therefore i replaced lib with lib64 in the debian/rules file, but this does not seem to change anything, which looks like this now:
sed -i -e '/dbus-python/d' debian/python-subscription-manager/usr/lib64/python2.7/site-packages/subscription_manager-1.25.1-py2.7.egg-info/requires.txt

I fixed the error. Compiling works now.

Change the ‘sed’ line in debian/rules was correct. But its not the lib, its the hardcoded version:
Change the following line:

sed -i -e '/dbus-python/d' debian/python-subscription-manager/usr/lib64/python2.7/site-packages/subscription_manager-1.25.1-py2.7.egg-info/requires.txt

into (it might depend on your version)

sed -i -e '/dbus-python/d' debian/python-subscription-manager/usr/lib/python2.7/site-packages/subscription_manager-1.26.2-py2.7.egg-info/requires.txt

Oh and I forgot one thing to mention: One line in the Makefile has to be changed:

PYTHON_SITELIB ?= $(PREFIX)/lib64/$(PYTHON_VER)/site-packages

to

PYTHON_SITELIB ?= $(PREFIX)/lib/$(PYTHON_VER)/site-packages

Now compiling should be successfull :wink:

These steps work, thank you.
What’s the next step once it is done building. This is my first time building.

Thanks,
AndyL

These steps works.

But now I have some other issue, questions. I have install all packages on ubuntu 18.04:

python-subscription-manager python-subscription-manager apt-transport-katello katello-upload-profile

server type: Red Hat Subscription Management
subscription management server: 3.12.3-Unknown
subscription management rules: 5.35
subscription-manager: 1.26.4-1-9-gb47736bf

and register client to Foreman and I got this error during registration:

root@zubuntu:~# subscription-manager register --org=“bla” --activationkey=“ubuntu_1804_key”
’NoneType’ object is not callable
root@zubuntu:~#

and in /var/log/rhsm/rhsm.log

2019-10-22 15:12:36,732 [INFO] subscription-manager:5303:MainThread @connection.py:905 - Connection built: host=foremansc.test.local port=443 handler=/rhsm auth=none
2019-10-22 15:12:43,931 [INFO] subscription-manager:5303:MainThread @managerlib.py:72 - Consumer created: zubuntu (75d0a750-ab07-4284-97a5-99540ec27397)
2019-10-22 15:12:43,933 [INFO] subscription-manager:5303:MainThread @connection.py:905 - Connection built: host=foremansc.test.local port=443 handler=/rhsm auth=identity_cert ca_dir=/etc/rhsm/ca/ insecure=False
2019-10-22 15:12:43,934 [ERROR] subscription-manager:5303:MainThread @managercli.py:216 - Error during registration: ‘NoneType’ object is not callable
2019-10-22 15:12:43,934 [ERROR] subscription-manager:5303:MainThread @managercli.py:217 - ‘NoneType’ object is not callable
Traceback (most recent call last):
File “/usr/lib/python2.7/dist-packages/subscription_manager/managercli.py”, line 1370, in _do_command
type=self.options.consumertype
File “/usr/lib/python2.7/dist-packages/rhsmlib/services/register.py”, line 102, in register
store = syspurposelib.SyncedStore(uep, consumer_uuid=self.identity.uuid)
TypeError: ‘NoneType’ object is not callable

Can I ignore this error?

client is visible in Foreman. I would like to know:

  1. do I have to create /etc/apt/sources.list by myself or should this be created automatically during registration, because I add apt repository to activation key?

  2. I have also create Lifecycle Environment/Content View and if I have to create /etc/apt/sources.list by myself I just don’t understand if I promote new version with new patches this mean that all clients will see new CV even if I don’t promote to all environment. Is that correct?

Thanks