Running hammer cli command with fields options in a debian docker container produces empty output

Problem:
I try to run the following command in a debian docker container. (But its happening as well in Debian WSL, Ubuntu WSL, Ubuntu Container):

hammer -s https://servername/ -u username-p password host info --location Z1 --organization Corporate --name abv10000vmx.z1 --fields 'Content Information/Applicable Errata/Bug Fix' 

Its producing a 2 line empty output.

What is working so far:

  • If I remove --fields the detailed information of the host are shown correctly

  • If I activate -d its showing the complete debug output with all erratas. I am using this currently as a workaround to get my erratas. Very hacky actually :D.

  • If I run it directly in the terminal of a orcharhino instance its showing everything correctly. The OS there is a oracle linux version 7.

Expected outcome:
Should return Erratas and not these empty lines

Foreman and Proxy versions:
We are using Orcharhino Version 5.7

  • foreman-2.1.3-57012.orcharhino.noarch
  • katello-3.16.2-1.el7.noarch

Foreman and Proxy plugin versions:

  • foreman-proxy-2.1.4-1.el7.noarch

Hammer CLI Version
2.4.0
Have tried the older version: 2.1.2, too => Same result

Distribution and version:
Debian Buster, Ubuntu 2004

My conclusion so far: Has something to do with the output of debian. As its just happening there.

Thanks for helping me out. Its actually a very critical part of an application that I am developing at the moment. It is creating security reports, getting the current erratas from servers in orcharhino. Its possible to use the API from orcharino. But this is like 10 times slower, than using the comand above. Its working currently with a workaround using the debug switch, but this is more a hacky way to use it. Not something we should use in production

Hi @DanielU

Are you seeing any tracebacks with the -d option when running the command in WSL? How did you install hammer inside of WSL Ubuntu, I will try to test it here on my Windows box and see what is missing.

3 Likes

In the end I want to use this command in a debian buster container. Not sure if its not better to use a debian wsl?

I have used these commands to install the hammer-cli:

sudo su -i
apt -y install gpg
wget -q https://deb.theforeman.org/foreman.asc -O- | apt-key add -
echo "deb http://deb.theforeman.org/ buster 2.4" > /etc/apt/sources.list.d/foreman.list 
apt -y update && apt -y install ruby-hammer-cli ruby-hammer-cli-foreman

I will test it on my debian wsl:
Result: No tracebacks and no errors. Just Debug Info.

Have tried to install current version 2.5
But in the repo its installing an older version 2.1 or 2.2.

Thanks for helping out :slight_smile:

1 Like

I am not familiar with containers sorry :frowning:

Let me see how I can get it working with WSL and then you can take that and translate it over to the Debian container. Happy to help!

@DanielU

I should have an answer for you by tomorrow or latest Monday. Still working on this.

2 Likes

Sounds good. Seems like its kind of the same cause.

:+1:

Hello,

as you said you have an answer by monday I thought about asking again:
How far are you with the solution for the problem?

Thanks.

@DanielU

Super sorry for the delay, I promise to have something you by end of day my time tomorrow. I had a few things that came up sadly.

@DanielU

I was able to get hammer installed and working on Ubuntu 20.04 and Ubuntu 20.04 in WSL

Here are the steps:

Getting hammer to work on Ubuntu 20.04 LTS

sudo apt-get install ruby ruby-dev build-essential
sudo gem install hammer_cli_katello
mkdir -p ~/.hammer/cli.modules.d
copy cli_config.yml from Katello server to ~/hammer
copy katello.yml from Katello server to ~/hammer/cli.modules.d
copy foreman.yml from Katello server to ~/hammer/cli.modules.d
hammer --fetch-ca-cert https:/fqndofkatelloserver
hammer -r

Ping output showing it is working:

chrobert@ubuntu:~$ hammer ping
database:         
    Status:          ok
    Server Response: Duration: 0ms
katello_agent:    
    Status:          ok
    message:         0 Processed, 0 Failed
    Server Response: Duration: 0ms
candlepin:        
    Status:          ok
    Server Response: Duration: 38ms
candlepin_auth:   
    Status:          ok
    Server Response: Duration: 28ms
candlepin_events: 
    Status:          ok
    message:         0 Processed, 0 Failed
    Server Response: Duration: 0ms
katello_events:   
    Status:          ok
    message:         0 Processed, 0 Failed
    Server Response: Duration: 0ms
pulp3:            
    Status:          ok
    Server Response: Duration: 219ms
foreman_tasks:    
    Status:          ok
    Server Response: Duration: 674ms

Screenshot of it working in Windows:

Update: needed to to do a apt update before installing it :D.
I will test your solution. Maybe it fixes my problem, although it seems to me not.

I just came to test it…unfortunately its not working in debian 10…
there is not installation candidate for ruby-dev.
Furthermore I am not sure if this will fix my problem.
The problem is not that hammer is not running. The problem is that its not printing all informations…

Another update:
I was successfull installing it your way.
And yeah its the solution, nice, thanks a lot =).

For future reference. For me this was enough:
sudo apt-get install ruby ruby-dev build-essential
sudo gem install hammer_cli_katello
mkdir -p ~/.hammer/cli.modules.d
then create katello.yml in this folder put this in there:
:katello: :enable_module: true
and foreman.yml an put this in there:
:foreman: :enable_module: true
in the end, fetch the ssl certificate:
hammer --fetch-ca-cert https:/fqndofkatelloserver

BTW:
Not sure how to format it correctly. Between the first words katello and foreman and the second there is a new line and 4 spaces.

I found out:
Its just the katello.yml needed. As foreman.yml is already per default in /etc/hammer/cli.modules.d and has the string :foreman: :enable_module: true activated!