Hammer error 'Error: undefined method `connection_options' for HammerCLI::Apipie::Command:Clas'

Problem:
I am having a problem running hammer commands. Every hammer command gives the following error:

# hammer host list
Error: undefined method `connection_options' for HammerCLI::Apipie::Command:Class
Warning: An error occured while loading module hammer_cli_foreman
Error: No such sub-command 'host'

See: 'hammer --help'

From an earlier thread, I noticed that for debugging the gem list was requested. So here it goes:

# hammer -d log
[ INFO 2018-02-23 05:59:28 Init] Initialization of Hammer CLI (0.10.2) has started...
[DEBUG 2018-02-23 05:59:28 Init] Running at ruby 2.2.2-p95
[ INFO 2018-02-23 05:59:28 Init] Configuration from the file /etc/hammer/cli_config.yml has been loaded
[ INFO 2018-02-23 05:59:28 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman.yml has been loaded
[ INFO 2018-02-23 05:59:28 Init] Configuration from the file /root/.hammer/cli.modules.d/foreman.yml has been loaded
[ERROR 2018-02-23 05:59:28 Exception] Error: undefined method `connection_options' for HammerCLI::Apipie::Command:Class
[ WARN 2018-02-23 05:59:28 HammerCLI::Output::Output] Required adapter '' was not found, using 'base' instead
Error: undefined method `connection_options' for HammerCLI::Apipie::Command:Class
[ERROR 2018-02-23 05:59:28 Exception] 

NoMethodError (undefined method `connection_options' for HammerCLI::Apipie::Command:Class):
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.8.0/lib/hammer_cli_foreman/commands.rb:42:in `foreman_api_connection'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.8.0/lib/hammer_cli_foreman/commands.rb:47:in `foreman_api'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.8.0/lib/hammer_cli_foreman/commands.rb:56:in `foreman_resource!'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.8.0/lib/hammer_cli_foreman/commands.rb:476:in `associated_resource'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.8.0/lib/hammer_cli_foreman/associating_commands.rb:40:in `<class:AddHostgroupCommand>'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.8.0/lib/hammer_cli_foreman/associating_commands.rb:39:in `<module:Hostgroup>'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.8.0/lib/hammer_cli_foreman/associating_commands.rb:36:in `<module:AssociatingCommands>'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.8.0/lib/hammer_cli_foreman/associating_commands.rb:2:in `<module:HammerCLIForeman>'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.8.0/lib/hammer_cli_foreman/associating_commands.rb:1:in `<top (required)>'
    /opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require'
    /opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.8.0/lib/hammer_cli_foreman.rb:27:in `<module:HammerCLIForeman>'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.8.0/lib/hammer_cli_foreman.rb:5:in `<top (required)>'
    /opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:128:in `require'
    /opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
    /opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:39:in `require'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.10.2/lib/hammer_cli/modules.rb:78:in `require_module'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.10.2/lib/hammer_cli/modules.rb:57:in `load!'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.10.2/lib/hammer_cli/modules.rb:72:in `load'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.10.2/lib/hammer_cli/modules.rb:83:in `block in load_all'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.10.2/lib/hammer_cli/modules.rb:82:in `each'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.10.2/lib/hammer_cli/modules.rb:82:in `load_all'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.10.2/bin/hammer:134:in `<top (required)>'
    /bin/hammer:23:in `load'
    /bin/hammer:23:in `<main>'


[ERROR 2018-02-23 05:59:28 Modules] Error while loading module hammer_cli_foreman
Warning: An error occured while loading module hammer_cli_foreman
[DEBUG 2018-02-23 05:59:28 Init] Using locale 'en'
[DEBUG 2018-02-23 05:59:28 Init] 'mo' files for locale domain 'hammer-cli' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.10.2/locale'
[DEBUG 2018-02-23 05:59:28 Init] 'mo' files for locale domain 'hammer-cli-foreman' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.8.0/locale'
[ INFO 2018-02-23 05:59:28 HammerCLI::MainCommand] Called with options: {"option_debug"=>true}
[ERROR 2018-02-23 05:59:28 Exception] Error: No such sub-command 'log'

See: 'hammer --help'
Error: No such sub-command 'log'

See: 'hammer --help'
[ERROR 2018-02-23 05:59:28 Exception] 

Clamp::UsageError (No such sub-command 'log'):
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/subcommand/execution.rb:28:in `find_subcommand_class'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/subcommand/execution.rb:17:in `instatiate_subcommand'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/subcommand/execution.rb:10:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.10.2/lib/hammer_cli/abstract.rb:29:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:133:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.10.2/bin/hammer:147:in `<top (required)>'
    /bin/hammer:23:in `load'
    /bin/hammer:23:in `<main>'

# gem list

*** LOCAL GEMS ***

addressable (2.4.0)
ansi (1.4.3)
apipie-bindings (0.0.13)
awesome_print (1.7.0, 1.0.2)
bigdecimal (1.2.0)
bolt (0.13.0)
builder (3.2.3)
bundler (1.7.8)
bundler_ext (0.3.0)
CFPropertyList (2.3.6)
clamp (1.0.0)
concurrent-ruby (1.0.0)
daemon_controller (1.1.2)
erubis (2.7.0)
facter (2.4.6)
facterdb (0.3.10)
fast_gettext (1.1.0, 0.9.2)
fastercsv (1.5.4)
ffi (1.9.10)
gettext (3.2.2)
gettext-setup (0.24)
gssapi (1.2.0, 1.1.2)
gyoku (1.3.1)
hashie (2.0.5)
hiera (3.3.1)
hiera-eyaml (2.1.0)
highline (1.6.21)
httpclient (2.8.3)
io-console (0.4.2)
jgrep (1.4.1)
json (1.7.7)
json_pure (1.8.6)
kafo (1.0.5)
kafo_parsers (0.1.5)
kafo_wizards (0.0.1)
little-plugger (1.1.3)
locale (2.1.2, 2.0.9)
logging (1.8.2)
mime-types (1.19)
minitar (0.6.1)
multi_json (1.10.1)
net-http-persistent (2.8)
net-scp (1.2.1)
net-ssh (4.2.0)
netrc (0.7.7)
nori (2.6.0)
oauth (0.4.7)
orchestrator_client (0.2.2)
powerbar (1.0.11)
psych (2.0.0)
puppet (4.10.1)
rack (1.6.4)
rack-protection (1.5.3)
rake (0.9.6)
rb-inotify (0.9.7)
rb-readline (0.5.1)
rdoc (4.0.0)
rest-client (1.6.7)
rkerberos (0.1.3)
rubyipmi (0.10.0)
rubyntlm (0.6.2)
rubyzip (1.2.1)
sinatra (1.3.5)
smart_proxy_dynflow (0.1.8)
smart_proxy_remote_execution_ssh (0.1.6)
stomp (1.3.2)
table_print (1.5.1)
terminal-table (1.8.0)
text (1.3.1)
thor (0.19.1)
tilt (1.3.7)
trollop (2.1.2)
unicode-display_width (1.3.0)
win32-dir (0.4.9)
win32-process (0.7.5)
win32-security (0.2.5)
win32-service (0.8.8)
winrm (2.2.3)
winrm-fs (1.1.1)

# foreman-rake plugin:list
Collecting plugin information
Foreman plugin: foreman-tasks, 0.9.6, Ivan Nečas, The goal of this plugin is to unify the way of showing task statuses across the Foreman instance.
It defines Task model for keeping the information about the tasks and Lock for assigning the tasks
to resources. The locking allows dealing with preventing multiple colliding tasks to be run on the
same resource. It also optionally provides Dynflow infrastructure for using it for managing the tasks.
Foreman plugin: foreman_remote_execution, 1.3.7, Foreman Remote Execution team, A plugin bringing remote execution to the Foreman, completing the config management functionality with remote management functionality.
Foreman plugin: foreman_setup, 5.0.0, Dominic Cleal, Plugin for Foreman that helps set up provisioning.

Expected outcome:

Hammer should run without any problem.

Foreman and Proxy versions:
How can I gather foreman and proxy versions?

Foreman and Proxy plugin versions:
See above

Note that this is my production Puppet server. So I am not in a position to perform intrusive changes.

On the Foreman server:
rpm -qa | grep foreman

Are you using hammer on the same machine that is Foreman or a different machine? If you’re running hammer on a different machine, please make sure you’re using the same repository versions of Foreman as your Foreman server. I see you have hammer-cli 0.10.2 and hammer-cli-foreman 0.8.0. These are quite old releases and won’t work with recent Foreman releases (i.e. 1.16).

1 Like

Hi,

Here is the foreman and proxy versions:

# rpm -qa | grep foreman
foreman-proxy-1.14.1-1.el7.noarch
foreman-cli-1.14.1-1.el7.noarch
foreman-selinux-1.14.1-1.el7.noarch
foreman-release-scl-3-1.el7.noarch
foreman-1.15.6-1.el7.noarch
tfm-rubygem-foreman-tasks-core-0.1.8-1.fm1_15.el7.noarch
tfm-rubygem-foreman-tasks-0.9.6-1.fm1_15.el7.noarch
tfm-rubygem-hammer_cli_foreman-0.8.0-1.el7.noarch
foreman-release-1.14.1-1.el7.noarch
foreman-installer-1.14.1-1.el7.noarch
foreman-debug-1.14.1-1.el7.noarch
tfm-rubygem-foreman_remote_execution-1.3.7-1.fm1_15.el7.noarch
foreman-postgresql-1.15.6-1.el7.noarch
tfm-rubygem-foreman_setup-5.0.0-1.fm1_13.el7.noarch
foreman-vmware-1.15.6-1.el7.noarch
tfm-rubygem-foreman_remote_execution_core-1.0.6-1.fm1_15.el7.noarch

And yes I am running them on the same host.

EDIT: Okay I see some version mismatch. For example, foreman-1.15.6-1.el7.noarch and foreman-release-1.14.1-1.el7.noarch. How do I reconcile these different versions?

I was pretty sure rpm dependencies would have disallowed you to install these packages together. If you want to run 1.15, you should update foreman-release to 1.15 as stated in the upgrade docs:

yum upgrade https://yum.theforeman.org/releases/1.15/el7/x86_64/foreman-release.rpm

Be sure to perform the other steps required to upgrade following that.

Thanks, I will try to upgrade and let you know.

Just to let you know that I tried this today and it worked fine. Only thing that I had to do outside of what is already in documentation is that I had to download the puppet master cert again with hammer --fetch-ca-cert https://puppetserver.org.

1 Like