Bug 1667973 - Unable to add smartclass parameter with matcher fqdn, when hosts installed with disabled option "add domain to hostname"
Summary: Unable to add smartclass parameter with matcher fqdn, when hosts installed wi...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Smart Variables
Version: 6.4.0
Hardware: x86_64
OS: Linux
unspecified
high
Target Milestone: 6.7.0
Assignee: satellite6-bugs
QA Contact: Peter Ondrejka
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-01-21 15:40 UTC by Steffen Froemer
Modified: 2020-04-14 13:24 UTC (History)
12 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-04-14 13:23:48 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 26909 0 Normal Closed Unable to add smartclass parameter with matcher fqdn, when hosts installed with disabled option "add domain to hostname" 2021-02-10 09:26:43 UTC
Red Hat Product Errata RHSA-2020:1454 0 None None None 2020-04-14 13:23:59 UTC

Description Steffen Froemer 2019-01-21 15:40:04 UTC
Description of problem:
When a host is installed with name and the satellite option "append domain name for hosts" is disabled, it's not possible to define a sc-parameter using hammer, which matches on fqdn.

Version-Release number of selected component (if applicable):
tfm-rubygem-hammer_cli-0.13.1.1-1.el7sat.noarch

How reproducible:
always

Steps to Reproduce:
1. hammer settings set --name 'append_domain_name_for_hosts' --value 'false'
2. hammer host create \
--ask-root-password 0 \
--build 1 \
--provision-method build \
--domain "crazy.lab" \
--hostgroup "HG-RHEL7-DEV" \
--subnet "crazy.lab" \
--organization "CRAZY LAB" \
--location "LOCAL" \
--name "rhelhosta" \
--compute-resource "libvirt@CHUNK"

3. hammer host start --name "rhelhosta"
4. hammer sc-param add-matcher --match 'fqdn=rhelhosta.crazy.lab' --value 'Good Morning' --smart-class-parameter content --puppet-class motd

Actual results:
Could not create the override value:
  Validation failed: Match fqdn=rhelhosta.crazy.lab does not match an existing host

Expected results:
A sc-parameter is added with matcher fqdn=rhelhosta.crazy.lab

Additional info:

# hammer fact list --search "rhelhost*"
----------|----------------------|--------------------
HOST      | FACT                 | VALUE
----------|----------------------|--------------------
rhelhosta | hostname             | rhelhosta
rhelhosta | networking::hostname | rhelhosta
rhelhosta | clientcert           | rhelhosta
rhelhosta | fqdn                 | rhelhosta.crazy.lab
rhelhosta | networking::fqdn     | rhelhosta.crazy.lab
----------|----------------------|--------------------

It's possible to add this parameter using 'hostname', but this results in not working puppet-rule, as fqdn=rhelhosta does not match facter-result.

# hammer sc-param add-matcher --match 'fqdn=rhelhosta' --value 'Good Morning!' --smart-class-parameter content --puppet-class motd
Override value created.

Comment 3 Steffen Froemer 2019-01-24 09:35:08 UTC
[root@sat6-1 ~]# hammer -d -vvv sc-param add-matcher --match 'fqdn=rhelhosta.crazy.lab' --value 'Good Morning!' --smart-class-parameter content --puppet-class motd
[ INFO 2019-01-24T08:55:38 Init] Initialization of Hammer CLI (0.13.1.1) has started...
[DEBUG 2019-01-24T08:55:38 Init] Running at ruby 2.4.5-p335
[ INFO 2019-01-24T08:55:38 Init] Configuration from the file /etc/hammer/cli_config.yml has been loaded
[ INFO 2019-01-24T08:55:38 Init] Configuration from the file /etc/hammer/cli.modules.d/csv.yml has been loaded
[ INFO 2019-01-24T08:55:38 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman.yml has been loaded
[ INFO 2019-01-24T08:55:38 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_admin.yml has been loaded
[ INFO 2019-01-24T08:55:38 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_admin_logging_core.yml has been loaded
[ INFO 2019-01-24T08:55:38 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_admin_logging_katello.yml has been loaded
[ INFO 2019-01-24T08:55:38 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_ansible.yml has been loaded
[ INFO 2019-01-24T08:55:38 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_bootdisk.yml has been loaded
[ INFO 2019-01-24T08:55:38 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_discovery.yml has been loaded
[ INFO 2019-01-24T08:55:38 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_docker.yml has been loaded
[ INFO 2019-01-24T08:55:38 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_openscap.yml has been loaded
[ INFO 2019-01-24T08:55:38 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_remote_execution.yml has been loaded
[ INFO 2019-01-24T08:55:38 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_tasks.yml has been loaded
[ INFO 2019-01-24T08:55:38 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_templates.yml has been loaded
[ INFO 2019-01-24T08:55:38 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_virt_who_configure.yml has been loaded
[ INFO 2019-01-24T08:55:38 Init] Configuration from the file /etc/hammer/cli.modules.d/katello.yml has been loaded
[ INFO 2019-01-24T08:55:38 Init] Configuration from the file /root/.hammer/cli_config.yml has been loaded
[ INFO 2019-01-24T08:55:38 Init] Configuration from the file /root/.hammer/defaults.yml has been loaded
[ INFO 2019-01-24T08:55:38 Init] Configuration from the file /root/.hammer/cli.modules.d/foreman.yml has been loaded
[DEBUG 2019-01-24T08:55:39 SSLoptions] SSL options: {
    :ssl_ca_file => "/etc/pki/katello/certs/katello-server-ca.crt",
     :verify_ssl => true
}
[DEBUG 2019-01-24T08:55:39 API] Global headers: {
        :content_type => "application/json",
              :accept => "application/json;version=2",
    "Accept-Language" => "en"
}
[DEBUG 2019-01-24T08:55:39 API] Follow redirects: never
[DEBUG 2019-01-24T08:55:39 Connection] Registered: foreman
[ INFO 2019-01-24T08:55:39 Modules] Extension module hammer_cli_foreman (0.13.2.2) loaded.
[ INFO 2019-01-24T08:55:39 Modules] Extension module hammer_cli_foreman_admin (0.0.8) loaded.
[ INFO 2019-01-24T08:55:39 Modules] Extension module hammer_cli_foreman_bootdisk (0.1.3.3) loaded.
[ INFO 2019-01-24T08:55:39 Modules] Extension module hammer_cli_foreman_discovery (1.0.0) loaded.
[ INFO 2019-01-24T08:55:39 Modules] Extension module hammer_cli_foreman_openscap (0.1.6) loaded.
[ INFO 2019-01-24T08:55:39 Modules] Extension module hammer_cli_foreman_templates (0.1.0) loaded.
[ INFO 2019-01-24T08:55:39 HammerCLI::MainCommand] subcommand organization (HammerCLIForeman::Organization) was removed.
[ INFO 2019-01-24T08:55:39 HammerCLI::MainCommand] subcommand organization (HammerCLIKatello::Organization) was created.
[ INFO 2019-01-24T08:55:39 Modules] Extension module hammer_cli_katello (0.13.4.3) loaded.
[DEBUG 2019-01-24T08:55:39 Init] Using locale 'en'
[DEBUG 2019-01-24T08:55:39 Init] 'mo' files for locale domain 'hammer-cli' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.13.1.1/locale'
[DEBUG 2019-01-24T08:55:39 Init] 'mo' files for locale domain 'hammer-cli-foreman' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.13.2.2/locale'
[DEBUG 2019-01-24T08:55:39 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 2019-01-24T08:55:39 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 2019-01-24T08:55:39 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 2019-01-24T08:55:39 Init] 'mo' files for locale domain 'hammer-cli-katello' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_katello-0.13.4.3/locale'
[ INFO 2019-01-24T08:55:39 HammerCLI::MainCommand] Called with options: {"option_verbose"=>true, "option_debug"=>true}
[ INFO 2019-01-24T08:55:39 HammerCLIForeman::SmartClassParameter] Called with options: {}
[ INFO 2019-01-24T08:55:40 API] Server: https://sat6-1.crazy.lab
[ INFO 2019-01-24T08:55:40 API] GET /api/puppetclasses
[DEBUG 2019-01-24T08:55:40 API] Params: {
    :search => "name = \"motd\""
}
[DEBUG 2019-01-24T08:55:40 API] Headers: {
    :params => {
        :search => "name = \"motd\""
    }
}
[DEBUG 2019-01-24T08:55:40 API] Using authenticator: HammerCLIForeman::Api::InteractiveBasicAuth
[DEBUG 2019-01-24T08:55:40 API] Response: {
       "total" => 6,
    "subtotal" => 1,
        "page" => 1,
    "per_page" => 20,
      "search" => "name = \"motd\"",
        "sort" => {
           "by" => nil,
        "order" => nil
    },
     "results" => {
        "motd" => [
            [0] {
                        "id" => 2,
                      "name" => "motd",
                "created_at" => "2019-01-17T10:21:18.713Z",
                "updated_at" => "2019-01-17T10:21:18.713Z"
            }
        ]
    }
}
[DEBUG 2019-01-24T08:55:40 API] Response headers: {
                                 :date => "Thu, 24 Jan 2019 07:55:40 GMT",
                               :server => "Apache/2.4.6 (Red Hat Enterprise Linux)",
                      :foreman_version => "1.18.0.39",
                  :foreman_api_version => "2",
                      :apipie_checksum => "759081e85831efc68bc9615965147242c8c1d492",
                        :cache_control => "max-age=0, private, must-revalidate",
                         :x_request_id => "56c7a8bf-e456-4b44-8bda-706ad269abf8",
                            :x_runtime => "0.052781",
              :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] "_session_id=bd506b2113092de1d438be142cc01a3b; path=/; secure; HttpOnly; SameSite=Lax"
    ],
                                 :etag => "W/\"67c2eeacbd7dc7258b711078585dc6d1-gzip\"",
                               :status => "200 OK",
                                 :vary => "Accept-Encoding",
                     :content_encoding => "gzip",
                       :content_length => "182",
                         :content_type => "application/json; charset=utf-8"
}
[ INFO 2019-01-24T08:55:40 API] Server: https://sat6-1.crazy.lab
[ INFO 2019-01-24T08:55:40 API] GET /api/puppetclasses/2/smart_class_parameters
[DEBUG 2019-01-24T08:55:40 API] Params: {
    :search => "key = \"content\""
}
[DEBUG 2019-01-24T08:55:40 API] Headers: {
    :params => {
        :search => "key = \"content\""
    }
}
[DEBUG 2019-01-24T08:55:40 API] Using authenticator: HammerCLIForeman::Api::InteractiveBasicAuth
[DEBUG 2019-01-24T08:55:40 API] Response: {
       "total" => 8,
    "subtotal" => 1,
        "page" => 1,
    "per_page" => 20,
      "search" => "key = \"content\"",
        "sort" => {
           "by" => nil,
        "order" => nil
    },
     "results" => [
        [0] {
                      "description" => nil,
                         "override" => true,
                   "parameter_type" => "string",
                    "hidden_value?" => false,
                             "omit" => nil,
                         "required" => false,
                   "validator_type" => nil,
                   "validator_rule" => nil,
                  "merge_overrides" => false,
                    "merge_default" => false,
                 "avoid_duplicates" => false,
             "override_value_order" => "fqdn\nhostgroup\nos\ndomain",
                       "created_at" => "2019-01-17 10:21:19 UTC",
                       "updated_at" => "2019-01-18 09:52:23 UTC",
               "use_puppet_default" => nil,
                 "puppetclass_name" => "motd",
                        "parameter" => "content",
                               "id" => 16,
                   "puppetclass_id" => 2,
            "override_values_count" => 1,
                    "default_value" => "undef"
        }
    ]
}
[DEBUG 2019-01-24T08:55:40 API] Response headers: {
                                 :date => "Thu, 24 Jan 2019 07:55:40 GMT",
                               :server => "Apache/2.4.6 (Red Hat Enterprise Linux)",
                      :foreman_version => "1.18.0.39",
                  :foreman_api_version => "2",
                      :apipie_checksum => "759081e85831efc68bc9615965147242c8c1d492",
                        :cache_control => "max-age=0, private, must-revalidate",
                         :x_request_id => "21eb42a0-26b7-457f-b905-d5fb452f4558",
                            :x_runtime => "0.060143",
              :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] "_session_id=b2bd169a722567dd87e4cd40b59b61ed; path=/; secure; HttpOnly; SameSite=Lax"
    ],
                                 :etag => "W/\"311480b62b3661ec1eb3bce59c492fdd-gzip\"",
                               :status => "200 OK",
                                 :vary => "Accept-Encoding",
                     :content_encoding => "gzip",
                       :content_length => "374",
                         :content_type => "application/json; charset=utf-8"
}
[ INFO 2019-01-24T08:55:40 HammerCLIForeman::SmartClassParameter::AddMatcherCommand] Called with options: {"option_value"=>"Good Morning!", "option_smart_class_parameter_name"=>"content", "option_smart_class_parameter_id"=>16, "option_match"=>"fqdn=rhelhosta.crazy.lab", "option_puppetclass_name"=>"motd"}
[ INFO 2019-01-24T08:55:40 API] Server: https://sat6-1.crazy.lab
[ INFO 2019-01-24T08:55:40 API] POST /api/smart_class_parameters/16/override_values
[DEBUG 2019-01-24T08:55:40 API] Params: {
    "override_value" => {
        "match" => "fqdn=rhelhosta.crazy.lab",
        "value" => "Good Morning!"
    }
}
[DEBUG 2019-01-24T08:55:40 API] Headers: {}
[DEBUG 2019-01-24T08:55:40 API] Using authenticator: HammerCLIForeman::Api::InteractiveBasicAuth
[ERROR 2019-01-24T08:55:40 API] 500 Internal Server Error
[DEBUG 2019-01-24T08:55:40 API] {
    "error" => {
        "message" => "Validation failed: Match fqdn=rhelhosta.crazy.lab does not match an existing host"
    }
}
[DEBUG 2019-01-24T08:55:40 Exception] Using exception handler HammerCLIForeman::ExceptionHandler#handle_internal_error
[ERROR 2019-01-24T08:55:40 Exception] Validation failed: Match fqdn=rhelhosta.crazy.lab does not match an existing host
Could not create the override value:
  Validation failed: Match fqdn=rhelhosta.crazy.lab does not match an existing host
[ERROR 2019-01-24T08:55:40 Exception]

RestClient::InternalServerError (500 Internal Server Error):
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-2.0.1/lib/restclient/abstract_response.rb:223:in `exception_with_response'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-2.0.1/lib/restclient/abstract_response.rb:103:in `return!'
    /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.2.2/lib/apipie_bindings/api.rb:353:in `block in rest_client_call_block'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-2.0.1/lib/restclient/request.rb:807:in `process_result'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-2.0.1/lib/restclient/request.rb:725:in `block in transmit'
    /opt/rh/rh-ruby24/root/usr/share/ruby/net/http.rb:877:in `start'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-2.0.1/lib/restclient/request.rb:715:in `transmit'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-2.0.1/lib/restclient/request.rb:145:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-2.0.1/lib/restclient/request.rb:52:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-2.0.1/lib/restclient/resource.rb:67:in `post'
    /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.2.2/lib/apipie_bindings/api.rb:327:in `call_client'
    /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.2.2/lib/apipie_bindings/api.rb:240:in `http_call'
    /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.2.2/lib/apipie_bindings/api.rb:190:in `call_action'
    /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.2.2/lib/apipie_bindings/api.rb:185:in `call'
    /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.2.2/lib/apipie_bindings/resource.rb:21:in `call'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.13.1.1/lib/hammer_cli/apipie/command.rb:51:in `send_request'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.13.2.2/lib/hammer_cli_foreman/commands.rb:168:in `send_request'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.13.1.1/lib/hammer_cli/apipie/command.rb:34:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/command.rb:63:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.13.1.1/lib/hammer_cli/abstract.rb:29:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/subcommand/execution.rb:11:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/command.rb:63:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.13.1.1/lib/hammer_cli/abstract.rb:29:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/subcommand/execution.rb:11:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/command.rb:63:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.13.1.1/lib/hammer_cli/abstract.rb:29:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/command.rb:132:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.13.1.1/bin/hammer:143:in `<top (required)>'
    /usr/bin/hammer:23:in `load'
    /usr/bin/hammer:23:in `<main>'

Comment 12 Bryan Kearney 2019-07-09 00:01:32 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/26909 has been resolved.

Comment 14 Peter Ondrejka 2020-01-28 15:18:31 UTC
Verified on Satellite 6.7 snap 10, using steps from problem description. It is now possible to override the smartclass parameter via fqdn for host created with append_domain_name_for_hosts set to false

Comment 17 errata-xmlrpc 2020-04-14 13:23:48 UTC
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-2020:1454


Note You need to log in before you can comment on or make changes to this bug.