Problem:
It seems that for us, using the register host functionality to register Ubuntu machines to Foreman-Katello is failing.
When it installs the subscription-manager it reports: dpkg: error: need an action option
which is odd, as the command looks fine in my eyes, running it manually also works withoud issues and the script also then continues like normal.
I’ve seen this issue on a freshly 24.04 Ubuntu machine aswell, but can also easily reproduce it on a test machine. I’ve debugged it as far as i could and this is waht i found:
In the registration script, we get to this point:
# rhn-client-tools conflicts with subscription-manager package
# since rhn tools replaces subscription-manager, we need to explicitly
# install subscription-manager after the rhn tools cleanup
if [ x$ID = xol ]; then
$PKG_MANAGER_REMOVE rhn-client-tools
$PKG_MANAGER_INSTALL --setopt=obsoletes=0 subscription-manager
elif [ -f /etc/debian_version ]; then
echo Debug-Hello
set -x
$PKG_MANAGER_INSTALL subscription-manager
fi
I’ve set that echo and set to show it in the logs below what happens when it fails:
## Running registration#Debug-Hello+ apt-get -o Dpkg::Options::='--force - Pastebin.com (it’s 80 lines, hence in pastebin).
Extract:
#
# Running registration
#
Debug-Hello
+ apt-get -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' install -y subscription-manager
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
apt-transport-go-katello libfsverity0 liblua5.3-0 librpm9t64 librpmbuild9t64 librpmio9t64 librpmsign9t64 python-dmidecode-data python3-dateutil python3-decorator
python3-dmidecode python3-iniparse python3-libxml2 python3-rpm python3-subscription-manager rpm-common virt-what
Suggested packages:
python3-subscription-manager-doc
The following NEW packages will be installed:
apt-transport-go-katello libfsverity0 liblua5.3-0 librpm9t64 librpmbuild9t64 librpmio9t64 librpmsign9t64 python-dmidecode-data python3-dateutil python3-decorator
python3-dmidecode python3-iniparse python3-libxml2 python3-rpm python3-subscription-manager rpm-common subscription-manager virt-what
0 upgraded, 18 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/3406 kB of archives.
After this operation, 12.1 MB of additional disk space will be used.
dpkg: error: need an action option
Type dpkg --help for help about installing and deinstalling packages [*];
Use 'apt' or 'aptitude' for user-friendly package management;
Type dpkg -Dhelp for a list of dpkg debug flag values;
Type dpkg --force-help for a list of forcing options;
Type dpkg-deb --help for help about manipulating *.deb files;
Options marked [*] produce a lot of output - pipe it through 'less' or 'more' !
E: Sub-process /usr/bin/dpkg returned an error code (2)
When i add this line: apt-get -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' install -y subscription-manager
directly into the script, just below the one that is made using variables:
apt-get -o Dpkg::Options::=‘–force-confdef’ -o Dpkg::Options::=‘–force-confold’ install -y subscription-manager
Log: ## Adding repository#Ign:1 https://foremandirectlyurltogetsubscriptoin-man - Pastebin.com
Extract:
#
# Running registration
#
Debug-Hello
+ apt-get -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' install -y subscription-manager
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
apt-transport-go-katello libfsverity0 liblua5.3-0 librpm9t64 librpmbuild9t64 librpmio9t64 librpmsign9t64 python-dmidecode-data python3-dateutil python3-decorator
python3-dmidecode python3-iniparse python3-libxml2 python3-rpm python3-subscription-manager rpm-common virt-what
Suggested packages:
python3-subscription-manager-doc
The following NEW packages will be installed:
apt-transport-go-katello libfsverity0 liblua5.3-0 librpm9t64 librpmbuild9t64 librpmio9t64 librpmsign9t64 python-dmidecode-data python3-dateutil python3-decorator
python3-dmidecode python3-iniparse python3-libxml2 python3-rpm python3-subscription-manager rpm-common subscription-manager virt-what
0 upgraded, 18 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/3406 kB of archives.
After this operation, 12.1 MB of additional disk space will be used.
dpkg: error: need an action option
Type dpkg --help for help about installing and deinstalling packages [*];
Use 'apt' or 'aptitude' for user-friendly package management;
Type dpkg -Dhelp for a list of dpkg debug flag values;
Type dpkg --force-help for a list of forcing options;
Type dpkg-deb --help for help about manipulating *.deb files;
Options marked [*] produce a lot of output - pipe it through 'less' or 'more' !
E: Sub-process /usr/bin/dpkg returned an error code (2)
+ echo Debug-Novars
Debug-Novars
+ apt-get -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold install -y subscription-manager
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
apt-transport-go-katello libfsverity0 liblua5.3-0 librpm9t64 librpmbuild9t64 librpmio9t64 librpmsign9t64 python-dmidecode-data python3-dateutil python3-decorator
python3-dmidecode python3-iniparse python3-libxml2 python3-rpm python3-subscription-manager rpm-common virt-what
Suggested packages:
python3-subscription-manager-doc
The following NEW packages will be installed:
apt-transport-go-katello libfsverity0 liblua5.3-0 librpm9t64 librpmbuild9t64 librpmio9t64 librpmsign9t64 python-dmidecode-data python3-dateutil python3-decorator
python3-dmidecode python3-iniparse python3-libxml2 python3-rpm python3-subscription-manager rpm-common subscription-manager virt-what
0 upgraded, 18 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/3406 kB of archives.
After this operation, 12.1 MB of additional disk space will be used.
Selecting previously unselected package apt-transport-go-katello.
(Reading database ... 128225 files and directories currently installed.)
Preparing to unpack .../00-apt-transport-go-katello_0.1.0-1_amd64.deb ...
It’s super weird, i’ve also updated to the latest foreman version just to be sure, as we came from rc1.
I’ve implemented a workaround to run the script and if it fails, to manually install subscription-manager and invoke it again.
That’s sufficient, but assuming this also happens in your test env/elsewhere, it’s smth i would like to help diagnose and fix
Expected outcome:
Registration script is run, and the host registers.
Foreman and Proxy versions:
Version 3.15.0 © (we don’t have proxies)
Foreman and Proxy plugin versions:
Name Description Author Version
foreman-tasks 11.0.0
foreman_ansible 16.0.0
foreman_azure_rm 3.0.3
foreman_discovery 11.0.1
foreman_remote_execution 16.0.3
foreman_rh_cloud 12.1.0
katello 4.17.0.rc1
puppetdb_foreman 6.0.2
Distribution and version:
Red Hat Enterprise Linux 9.6 (Plow)
Other relevant data:
As shown above:
We do make sure to offer the repo’s of Ubuntu and atix repo’s internally, the script adds these automatically and is also able to download/install what it needs before it’s registered.
Current output: ## Running registration#Debug-Hello+ apt-get -o Dpkg::Options::='--force - Pastebin.com
Adjusted script output using no variable for installing subscription-manager logs: ## Adding repository#Ign:1 https://foremandirectlyurltogetsubscriptoin-man - Pastebin.com
We also make sure to daily have the latest updates available.