Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2036446

Summary: Hammer unnecessarily removes single quote characters from Remote Execution jobs
Product: Red Hat Satellite Reporter: Pablo Hess <phess>
Component: HammerAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED DUPLICATE QA Contact: Gaurav Talreja <gtalreja>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.10.1CC: apatel, janarula, kgaikwad, ofedoren, rabajaj
Target Milestone: Unspecified   
Target Release: Unused   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-01-03 16:07:13 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Pablo Hess 2022-01-01 19:49:52 UTC
Description of problem:
When running a hammer command to invoke a Remote Execution job, the command passed as `--inputs` to hammer has its single quote characters incorrectly removed, e.g.

hammer -d job-invocation create \
   --job-template "Run Command - SSH Default" \
   --search-query "host_collection = my_host_collection" \
   --inputs command="/bin/rpm -qa --last | grep '1 Jan 2022'"


This results in hammer passing the parameters below to the foreman API:
(Note the missing closing single-quote character at the end of the command.)

[ INFO 2022-01-01T14:34:20 HammerCLIForemanRemoteExecution::JobInvocation::CreateCommand] Called with options: {"option_inputs"=>{"command"=>"/bin/rpm -qa --last | grep '1 Jan 2022"}, "option_job_template_name"=>"Run Command - SSH Default", "option_search_query"=>"host_collection = my_host_collection", "option_job_template_id"=>158}
[ INFO 2022-01-01T14:34:20 API] Server: https://sat610b.usersys.redhat.com
[ INFO 2022-01-01T14:34:20 API] POST /api/job_invocations
[DEBUG 2022-01-01T14:34:20 API] Params: {
    "job_invocation" => {
            "job_template_id" => 158,
                     "inputs" => {
            "command" => "/bin/rpm -qa --last | grep '1 Jan 2022"
        },
                        "ssh" => {},
                 "recurrence" => {},
                 "scheduling" => {},
        "concurrency_control" => {},
               "search_query" => "host_collection = my_host_collection",
             "targeting_type" => "static_query"
    }
}



Version-Release number of selected component (if applicable):
tfm-rubygem-hammer_cli-2.5.1-1.el7sat.noarch
tfm-rubygem-hammer_cli_foreman_remote_execution-0.2.1-2.el7sat.noarch


How reproducible:
Every time.

Steps to Reproduce:
1. Run a hammer command to invoke a Remote Execution command with the `Run Command - SSH Default` job template; the command being passed as a `--inputs` argument contains a pair of single quotes, e.g. 
====
hammer -d job-invocation create \
   --job-template "Run Command - SSH Default" \
   --search-query "host_collection = my_host_collection" \
   --inputs command="/bin/rpm -qa --last | grep '1 Jan 2022'"
====


Actual results:
Hammer "eats" the last single-quote character, so the command becomes syntactically incorrect for the target host's shell and the job inevitably fails.



Expected results:
Hammer would not modify quotes from the command that was passed as a `--inputs` argument and the command would be passed onto the target host exactly as typed on the hammer command line.


Additional info:
Hammer will also unexpectedly remove a single-quote character if I select the "Run Command - Ansible Default" job template instead of the "Run Command - SSH Default" template.

Comment 1 Oleh Fedorenko 2022-01-03 16:07:13 UTC
This was solved for https://bugzilla.redhat.com/show_bug.cgi?id=2022649. Please, feel free to re-open if it will still be valid.

*** This bug has been marked as a duplicate of bug 2022649 ***