Hammer Cli getting error while creating host


#1

Hello,
I am trying to deploy multiple hosts using hammer. but while creating host getting the below error. can anyone help here pls. I am not able find what I am missing?

hammer host create --name ca-test1 --hostgroup dev-testing --interface="primary=eth0, \

provision= true, \

mac=xx:xx:xx:xx:xx:xx, \

ip=xx:xx:xx:xx" --organization-id 1 --location-id 2 --ask-root-password yes

Enter the root password for the host:

Error:
Could not create the host:

Resource host not found by id ‘’

Thanks,
CS


#2

Hi,

could you please share the content of /var/log/foreman/production.log from that timeframe?
Maybe there are more information on the underlying problem.
Also, what version of Foreman are you running and which plugins do you have installed? (If in doubt, the About page under Administer in the WebUI will tell you)

Regards


#3

Thanks Areyus.
Getting the below error:

Parameters: {"location_id"=>2, "organization_id"=>1, "host"=>{"name"=>"ca-test1", "location_id"=>2, "organization_id"=>1, "puppetclass_ids"=>[], "hostgroup_id"=>1, "compute_attributes"=>{"volumes_attributes"=>{}}, "build"=>true, "managed"=>true, "enabled"=>true, "overwrite"=>true, "interfaces_attributes"=>[{"primary"=>"eth0", "provision"=>"true", "mac"=>"xx:xx:Xx:Xx", "ip"=>"xx:xx:xx:xx"}], "root_pass"=>"[FILTERED]"}, "apiv"=>"v2"}

2019-07-11T17:30:45 [I|app|702edf84] Authorized user admin(Admin User)

2019-07-11T17:30:45 [I|app|702edf84] Current user set to admin (admin)

2019-07-11T17:30:45 [I|app|702edf84] Couldn't find Hostgroup with 'id'=1 [WHERE (1=0)] (ActiveRecord::RecordNotFound)

2019-07-11T17:30:45 [I|app|702edf84] Rendering api/v2/errors/not_found.json.rabl within api/v2/layouts/error_layout

2019-07-11T17:30:45 [I|app|702edf84] Rendered api/v2/errors/not_found.json.rabl within api/v2/layouts/error_layout (0.5ms)

this is how I am using the command:

hammer host create --name ca-test1 --hostgroup dev-test --interface="primary=eth0

I already created the HG:

---|-----------|-----------|------------------|--------------------|------
ID | NAME      | TITLE     | OPERATING SYSTEM | PUPPET ENVIRONMENT | MODEL
---|-----------|-----------|------------------|--------------------|------
1  | dev-test  | dev-test  | Centos 7.4       | VMware             |      
---|-----------|-----------|------------------|--------------------|------

Thanks,
CS


#4

From the logs, it looks like the hostgroup can not be found.
Could you please share the output of 'hammer hostgroup info --id 1?
I would assume that the HG is not assiciated to your organization or location (or both).

Regards


#5

Thanks Areyus. Now I am able to create hosts using hammer.
But seeing the below error on Template fields:
I selected required templates btw in Image and host group as well.

2019-07-13T00:17:01 [W|app|fd2bb3c4] Failed to fetch templates information

Foreman::Exception: ERF42-7633 [Foreman::Exception]: No templates found

/usr/share/foreman/app/controllers/hosts_controller.rb:839:in `find_templates’

/usr/share/foreman/app/controllers/hosts_controller.rb:303:in `templates’

/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/a


#6

I would assume this is that same problem.
Please check if all your required templates (partitioning templates, provisioning templates, snippets, PXELinux templates) are associated with your Organization and Location.

Regards