Description of problem: `hammer host create --puppet-class-ids=6 ...` creates a host without mentioned puppet class attached Version-Release number of selected component (if applicable): satellite-6.4.0-9.beta.el7sat.noarch How reproducible: always Steps to Reproduce: 1. # hammer -d -v -u admin -p changeme host create --architecture-id="1" --domain-id="4" --environment-id="6" --ip="186.107.94.90" --location-id="2" --mac="4c:f7:c4:84:e2:92" --medium-id="11" --name="jhutar$RANDOM" --operatingsystem-id="2" --organization-id="1" --partition-table-id="94" --puppet-class-ids="6" --root-password="..." 2. # hammer -v -u admin -p changeme host puppet-classes --host-id 6 Actual results: # hammer -v -u admin -p changeme host puppet-classes --host-id 6 ---|----- ID | NAME ---|----- Expected results: # hammer -v -u admin -p changeme host puppet-classes --host-id 6 ---|---------- ID | NAME ---|---------- 6 | generic_1 ---|---------- Additional info: Looks like param is correctly passed in at the request time, but is not returned in the response: # hammer -d -v -u admin -p changeme host create --architecture-id="1" --domain-id="4" --environment-id="6" --ip="186.107.94.90" --location-id="2" --mac="4c:f7:c4:84:e2:92" --medium-id="11" --name="jhutar$RANDOM" --operatingsystem-id="2" --organization-id="1" --partition-table-id="94" --puppet-class-ids="6" --root-password="GKdvnWhu" [ INFO 2018-06-26T05:05:22 Init] Initialization of Hammer CLI (0.13.0) has started... [DEBUG 2018-06-26T05:05:22 Init] Running at ruby 2.4.3-p205 [ INFO 2018-06-26T05:05:22 Init] Configuration from the file /etc/hammer/cli_config.yml has been loaded [ INFO 2018-06-26T05:05:22 Init] Configuration from the file /etc/hammer/cli.modules.d/csv.yml has been loaded [ INFO 2018-06-26T05:05:22 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman.yml has been loaded [ INFO 2018-06-26T05:05:22 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_admin.yml has been loaded [ INFO 2018-06-26T05:05:22 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_admin_logging_core.yml has been loaded [ INFO 2018-06-26T05:05:22 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_admin_logging_katello.yml has been loaded [ INFO 2018-06-26T05:05:22 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_bootdisk.yml has been loaded [ INFO 2018-06-26T05:05:22 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_discovery.yml has been loaded [ INFO 2018-06-26T05:05:22 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_docker.yml has been loaded [ INFO 2018-06-26T05:05:22 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_openscap.yml has been loaded [ INFO 2018-06-26T05:05:22 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_remote_execution.yml has been loaded [ INFO 2018-06-26T05:05:22 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_tasks.yml has been loaded [ INFO 2018-06-26T05:05:22 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_templates.yml has been loaded [ INFO 2018-06-26T05:05:22 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_virt_who_configure.yml has been loaded [ INFO 2018-06-26T05:05:22 Init] Configuration from the file /etc/hammer/cli.modules.d/katello.yml has been loaded [ INFO 2018-06-26T05:05:22 Init] Configuration from the file /root/.hammer/cli.modules.d/foreman.yml has been loaded [DEBUG 2018-06-26T05:05:22 SSLoptions] SSL options: { :ssl_ca_file => "/etc/pki/katello/certs/katello-server-ca.crt", :verify_ssl => true } [DEBUG 2018-06-26T05:05:22 API] Global headers: { :content_type => "application/json", :accept => "application/json;version=2", "Accept-Language" => "en" } [DEBUG 2018-06-26T05:05:22 API] Follow redirects: never [DEBUG 2018-06-26T05:05:22 Connection] Registered: foreman [ INFO 2018-06-26T05:05:22 Modules] Extension module hammer_cli_foreman (0.13.0) loaded. [ INFO 2018-06-26T05:05:22 Modules] Extension module hammer_cli_foreman_admin (0.0.8) loaded. [ INFO 2018-06-26T05:05:22 Modules] Extension module hammer_cli_foreman_bootdisk (0.1.3.3) loaded. [ INFO 2018-06-26T05:05:22 Modules] Extension module hammer_cli_foreman_discovery (1.0.0) loaded. [ INFO 2018-06-26T05:05:22 Modules] Extension module hammer_cli_foreman_openscap (0.1.6) loaded. [ INFO 2018-06-26T05:05:23 Modules] Extension module hammer_cli_foreman_templates (0.1.0) loaded. [ INFO 2018-06-26T05:05:23 HammerCLI::MainCommand] subcommand organization (HammerCLIForeman::Organization) was removed. [ INFO 2018-06-26T05:05:23 HammerCLI::MainCommand] subcommand organization (HammerCLIKatello::Organization) was created. [ INFO 2018-06-26T05:05:23 Modules] Extension module hammer_cli_katello (0.13.1) loaded. [DEBUG 2018-06-26T05:05:23 Init] Using locale 'en' [DEBUG 2018-06-26T05:05:23 Init] 'mo' files for locale domain 'hammer-cli' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.13.0/locale' [DEBUG 2018-06-26T05:05:23 Init] 'mo' files for locale domain 'hammer-cli-foreman' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.13.0/locale' [DEBUG 2018-06-26T05:05:23 Init] 'mo' files for locale domain 'hammer-cli-csv' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_csv-2.3.1/locale' [DEBUG 2018-06-26T05:05:23 Init] 'mo' files for locale domain 'hammer_cli_foreman_docker' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman_docker-0.0.6/locale' [DEBUG 2018-06-26T05:05:23 Init] 'mo' files for locale domain 'hammer-cli-foreman-virt-who-configure' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman_virt_who_configure-0.0.3/locale' [DEBUG 2018-06-26T05:05:23 Init] 'mo' files for locale domain 'hammer-cli-katello' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_katello-0.13.1/locale' [ INFO 2018-06-26T05:05:23 HammerCLI::MainCommand] Called with options: {"option_verbose"=>true, "option_debug"=>true, "option_username"=>"admin", "option_password"=>"***"} [ INFO 2018-06-26T05:05:23 HammerCLIForeman::Host] Called with options: {} [ INFO 2018-06-26T05:05:23 HammerCLIForeman::Host::CreateCommand] Called with options: {"option_root_password"=>"***", "option_puppetclass_ids"=>["6"], "option_managed"=>true, "option_build"=>true, "option_enabled"=>true, "option_overwrite"=>true, "option_volume_list"=>[], "option_interface_list"=>[], "option_location_id"=>2, "option_organization_id"=>1, "option_environment_id"=>6, "option_architecture_id"=>1, "option_domain_id"=>4, "option_operatingsystem_id"=>2, "option_medium_id"=>11, "option_ptable_id"=>94, "option_name"=>"jhutar17000", "option_ip"=>"186.107.94.90", "option_mac"=>"4c:f7:c4:84:e2:92"} [ INFO 2018-06-26T05:05:23 API] Server: https://<fqdn> [ INFO 2018-06-26T05:05:23 API] POST /api/hosts [DEBUG 2018-06-26T05:05:23 API] Params: { "location_id" => 2, "organization_id" => 1, "host" => { "name" => "jhutar17000", "location_id" => 2, "organization_id" => 1, "environment_id" => 6, "ip" => "186.107.94.90", "mac" => "4c:f7:c4:84:e2:92", "architecture_id" => 1, "domain_id" => 4, "puppetclass_ids" => [ [0] "6" ], "operatingsystem_id" => 2, "medium_id" => 11, "ptable_id" => 94, "build" => true, "enabled" => true, "managed" => true, "compute_attributes" => { "volumes_attributes" => {} }, "content_facet_attributes" => {}, "subscription_facet_attributes" => {}, "overwrite" => true, "host_parameters_attributes" => [], "interfaces_attributes" => [], "root_pass" => "GKdvnWhu" } } [DEBUG 2018-06-26T05:05:23 API] Headers: {} [DEBUG 2018-06-26T05:05:23 API] Using authenticator: HammerCLIForeman::Api::InteractiveBasicAuth [DEBUG 2018-06-26T05:05:23 API] Response: { "ip" => "186.107.94.90", "ip6" => nil, "environment_id" => 6, "environment_name" => nil, "last_report" => nil, "mac" => "4c:f7:c4:84:e2:92", "realm_id" => nil, "realm_name" => nil, "sp_mac" => nil, "sp_ip" => nil, "sp_name" => nil, "domain_id" => 4, "domain_name" => "g4okrdnfrz", "architecture_id" => 1, "architecture_name" => "x86_64", "operatingsystem_id" => 2, "operatingsystem_name" => "RedHat 7.4", "subnet_id" => nil, "subnet_name" => nil, "subnet6_id" => nil, "subnet6_name" => nil, "sp_subnet_id" => nil, "ptable_id" => 94, "ptable_name" => "Kickstart default", "medium_id" => 11, "medium_name" => "QkHGAC", "pxe_loader" => "Grub2 UEFI", "build" => true, "comment" => nil, "disk" => nil, "installed_at" => nil, "model_id" => nil, "hostgroup_id" => nil, "owner_id" => 4, "owner_name" => "Admin User", "owner_type" => "User", "enabled" => true, "managed" => true, "use_image" => nil, "image_file" => "", "uuid" => nil, "compute_resource_id" => nil, "compute_resource_name" => nil, "compute_profile_id" => nil, "compute_profile_name" => nil, "capabilities" => [ [0] "build" ], "provision_method" => "build", "certname" => "jhutar17000.g4okrdnfrz", "image_id" => nil, "image_name" => nil, "created_at" => "2018-06-26 09:05:23 UTC", "updated_at" => "2018-06-26 09:05:23 UTC", "last_compile" => nil, "global_status" => 0, "global_status_label" => "OK", "organization_id" => 1, "organization_name" => "Default Organization", "location_id" => 2, "location_name" => "Default Location", "puppet_status" => 0, "model_name" => nil, "build_status" => 1, "build_status_label" => "Pending installation", "name" => "jhutar17000.g4okrdnfrz", "id" => 6, "puppet_proxy_id" => nil, "puppet_proxy_name" => nil, "puppet_ca_proxy_id" => nil, "puppet_ca_proxy_name" => nil, "openscap_proxy_id" => nil, "openscap_proxy_name" => nil, "puppet_proxy" => nil, "puppet_ca_proxy" => nil, "openscap_proxy" => nil, "token" => "efb44722-ee46-442f-9dc5-9056f33a2c88", "hostgroup_name" => nil, "hostgroup_title" => nil, "parameters" => [], "all_parameters" => [], "interfaces" => [ [0] { "id" => 10, "name" => "jhutar17000.g4okrdnfrz", "ip" => "186.107.94.90", "ip6" => nil, "mac" => "4c:f7:c4:84:e2:92", "mtu" => nil, "fqdn" => "jhutar17000.g4okrdnfrz", "identifier" => nil, "primary" => true, "provision" => true, "type" => "interface" } ], "puppetclasses" => [], "config_groups" => [], "all_puppetclasses" => [], "permissions" => { "view_hosts" => true, "create_hosts" => true, "edit_hosts" => true, "destroy_hosts" => true, "build_hosts" => true, "power_hosts" => true, "console_hosts" => true, "ipmi_boot_hosts" => true, "puppetrun_hosts" => true, "play_roles_on_host" => true, "view_discovered_hosts" => true, "submit_discovered_hosts" => true, "auto_provision_discovered_hosts" => true, "provision_discovered_hosts" => true, "edit_discovered_hosts" => true, "destroy_discovered_hosts" => true } } [DEBUG 2018-06-26T05:05:23 API] Response headers: { :date => "Tue, 26 Jun 2018 09:05:23 GMT", :server => "Apache/2.4.6 (Red Hat Enterprise Linux)", :foreman_version => "1.18.0-RC1", :foreman_api_version => "2", :apipie_checksum => "852e93a6ac5deceb3d5b1fd20892055915485bbe", :cache_control => "max-age=0, private, must-revalidate", :x_request_id => "048b4fc4-997b-4600-915d-c1d4dc887de5", :x_runtime => "0.266140", :content_security_policy => "default-src 'self'; child-src 'self'; connect-src 'self' ws: wss:; img-src 'self' data: *.gravatar.com; script-src 'unsafe-eval' 'unsafe-inline' 'self'; style-src 'unsafe-inline' 'self'", :strict_transport_security => "max-age=631139040; includeSubdomains", :x_content_type_options => "nosniff", :x_download_options => "noopen", :x_frame_options => "sameorigin", :x_permitted_cross_domain_policies => "none", :x_xss_protection => "1; mode=block", :x_powered_by => "Phusion Passenger 4.0.18", :set_cookie => [ [0] "request_method=POST; path=/; secure; HttpOnly; SameSite=Lax", [1] "_session_id=3e5b178495d31836691b1e288d2f90e5; path=/; secure; HttpOnly; SameSite=Lax" ], :etag => "W/\"6095775f92075c5b48d54c7704d642f7\"", :status => "201 Created", :transfer_encoding => "chunked", :content_type => "application/json; charset=utf-8" } Host created. production.log seems sane: ==> /var/log/foreman/production.log <== 2018-06-26T05:05:23 [I|app|] Started POST "/api/hosts" for 10.16.184.126 at 2018-06-26 05:05:23 -0400 2018-06-26T05:05:23 [I|app|048b4] Processing by Api::V2::HostsController#create as JSON 2018-06-26T05:05:23 [I|app|048b4] Parameters: {"location_id"=>2, "organization_id"=>1, "host"=>{"name"=>"jhutar17000", "location_id"=>2, "organization_id"=>1, "environment_id"=>6, "ip"=>"186.107.94.90", "mac"=>"4c:f7:c4:84:e2:92", "architecture_id"=>1, "domain_id"=>4, "puppetclass_ids"=>["6"], "operatingsystem_id"=>2, "medium_id"=>11, "ptable_id"=>94, "build"=>true, "enabled"=>true, "managed"=>true, "compute_attributes"=>{"volumes_attributes"=>{}}, "content_facet_attributes"=>{}, "subscription_facet_attributes"=>{}, "overwrite"=>true, "host_parameters_attributes"=>[], "interfaces_attributes"=>[], "root_pass"=>"[FILTERED]"}, "apiv"=>"v2"} 2018-06-26T05:05:23 [I|app|048b4] Current user: foreman_admin (administrator) 2018-06-26T05:05:23 [I|app|048b4] Authorized user admin(Admin User) 2018-06-26T05:05:23 [I|app|048b4] Current user: admin (administrator) 2018-06-26T05:05:23 [I|aud|048b4] create event for Nic::Managed with id 10 2018-06-26T05:05:23 [I|aud|048b4] create event for Host::Base with id 6 2018-06-26T05:05:23 [I|app|048b4] Rendering api/v2/hosts/create.json.rabl 2018-06-26T05:05:23 [I|app|048b4] Rendered api/v2/hosts/create.json.rabl (42.0ms) 2018-06-26T05:05:23 [I|app|048b4] Completed 201 Created in 259ms (Views: 37.9ms | ActiveRecord: 33.2ms) And you can fix it with `hammer host update...`: # hammer -v -u admin -p changeme host puppet-classes --host-id 6 ---|----- ID | NAME ---|----- # hammer -v -u admin -p changeme host update --id 6 --puppet-class-ids 6 Host updated. # hammer -v -u admin -p changeme host puppet-classes --host-id 6 ---|---------- ID | NAME ---|---------- 6 | generic_1 ---|----------
foreman-debug is in attachment 1454612 [details].
Hi Jan, do you know if this is a regression from 6.3? I suspect it may be.
Yes, you are right, this is a regression compared to 6.3. Thank you.
@jan: I was able to reproduce this issue, when the puppet environment was not assigned to the org/loc of the host. Is it possible that this would also be your case?
Created attachment 1456365 [details] organizations in the environment Soo, looks like it might be it. On the other hand, see scereenshot: Org 1 seems to be selected for that environment, but when I query env details via hammer: [root@sat640snap10 ~]# hammer -u admin -p changeme environment info --name KT_pTfgsH_Library_TRRpefOPzv_5 Id: 6 Name: KT_pTfgsH_Library_TRRpefOPzv_5 Puppetclasses: access_insights_client foreman_scap_client foreman_scap_client::params generic_1 stdlib stdlib::stages Locations: Default Location Organizations: pTfgsH Created at: 2018/07/04 05:23:32 Updated at: 2018/07/04 05:23:32
So you were right: when I imported the env into org 1 (it did not worked, I had to remove the the host with that class first), it now works. It worked before this in the 6.3, but I agree it seems more deterministic now when thinking about it. Does it make sense to create a bug for "I'm unable to import env if host supposedly consuming its class exists"?
Have you actually try to save the environment in the state of the screenshot? From my testing, it actually saved the org/location assignment after that. I think it makes sense to open a bug, that would visually indicate, that there are some inconsistencies in organizations/locations assigned to the taxable object and the hosts assigned to that object, and suggesting the user to save the resource to resolve those. As part of this bug, I would try to fix that by explicitly checking, that the environment that one tries to assign the host to, is actually inside the org/location of that particular host, and failing with validation issue.
Uch, I have not. Did not knew it works this way. Thank you.
Created redmine issue https://projects.theforeman.org/issues/24199 from this bug
Upstream bug assigned to inecas
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/24199 has been resolved.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHSA-2018:2927