Bug 2022649
Summary: | Hammer unable to send correct value for for Job Templates in order to update ALL packages. | ||
---|---|---|---|
Product: | Red Hat Satellite | Reporter: | Jaskaran Singh Narula <janarula> |
Component: | Hammer | Assignee: | Oleh Fedorenko <ofedoren> |
Status: | CLOSED ERRATA | QA Contact: | Gaurav Talreja <gtalreja> |
Severity: | medium | Docs Contact: | |
Priority: | unspecified | ||
Version: | 6.9.0 | CC: | apatel, aruzicka, kgaikwad, lstejska, ofedoren, phess, pmendezh, rabajaj |
Target Milestone: | 6.12.0 | Keywords: | Triaged |
Target Release: | Unused | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | If docs needed, set a value | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2022-11-16 13:32:59 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
Jaskaran Singh Narula
2021-11-12 09:44:10 UTC
I'm not sure I follow, it seems to work for me. Could you run the following and paste the full log and part of production.log from around that time? hammer -v -d job-invocation create --job-template "Package Action - Ansible Default" \ --inputs state="latest",name="*",post_script="needs-restarting -r || shutdown -r +1" \ --search-query "client_hostname" Also, could you check the same but using json syntax for the inputs? hammer -v -d job-invocation create --job-template "Package Action - Ansible Default" \ --inputs '{"state": "latest", "name": "*", "post_script": "needs-restarting -r || shutdown -r +1"}' \ --search-query "client_hostname" Oh, ok, the case actually had enough information to go by. If a single asterisk is passed in, the rendered template contains a task definition which looks like this. - package: name: * state: latest Ansible doesn't like this as it expects the asterisk to be wrapped in quotes. However, hammer apparently strips quotes from inputs so it is tricky to pass the right value. From my point of view, this is a bug in hammer, not REX itself. The following should work without any code changes. hammer -v -d job-invocation create --job-template "Package Action - Ansible Default" \ --inputs '{"state": "latest", "name": "\"*\"", "post_script": "needs-restarting -r || shutdown -r +1"}' \ --search-query "client_hostname" Created redmine issue https://projects.theforeman.org/issues/34079 from this bug Upstream bug assigned to ofedoren Upstream bug assigned to ofedoren Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/34079 has been resolved. The bug was fixed in the upstream and will lend into the next major hammer release (unless someone marks this for CPing).
The one important note: to make the previous command work, one must specify that the quotes in a string are actually required by escaping them with \. Thus, with this fix, the command should look like:
> hammer job-invocation create --job-template "Package Action - Ansible Default" --inputs state=latest,name=\"*\",post_script="needs-restarting -r || shutdown -r +1" --search-query "client_hostname"
*** Bug 2036446 has been marked as a duplicate of this bug. *** Hi, Tested this on Satellite 6.12.0 Snap 12.0 with rubygem-hammer_cli-3.3.0-1.el8sat.noarch 1. Setup Satellite, register a content_host and configure REX 2. Try following commands with yaml and json syntax to update all packages with asterisk wrapped in quotes # hammer -v -d job-invocation create --job-template "Package Action - Ansible Default" --inputs state="latest",name="\"*\"",post_script="needs-restarting -r || shutdown -r +1" --search-query name~client_hostname # hammer -v -d job-invocation create --job-template "Package Action - Ansible Default" --inputs '{"state": "latest", "name": "\"*\"", "post_script": "needs-restarting -r || shutdown -r +1"}' --search-query name~client_hostname # hammer -v -d job-invocation create --job-template "Package Action - Ansible Default" --inputs state=latest,name=\"*\",post_script="needs-restarting -r || shutdown -r +1" --search-query name~client_hostname Observations: Using the above commands, all packages have been updated on the client with the asterisk escaped in the name input. Furthermore, I've noticed that REX commands are used differently with 6.12, such as when testing "Run Command - Ansible Default" job template with input passed as --inputs="command=\'useradd -m testuser\'". Despite starting, the job failed because it attempted to run \'useradd -m testuser\' literally with the backslashes on the client, where hammer added one more slash //'useradd -m sZCNyGDzws//', which was not the case with 6.11. However, it works fine if input is passed as --inputs="command=useradd -m testuser", so I would like to check if this is expected behavior of this command? If not, Do you think we can move this BZ back to ASSIGNED?? Thanks, Gaurav This is a bit tricky. On one hand I'd say --inputs "command='foo'" should be treated as foo in single quotes hence the new behavior is correct, on the other hand, I'm not sure how multiple inputs are now distinguished. I'll defer to Oleh Adding needinfo for Oleh based upon comment 11 ("defer to Oleh"). Oleh, can you look over this bugzilla and provide your input? Hello, Answering on https://bugzilla.redhat.com/show_bug.cgi?id=2022649#c10: yes, this is expected behavior now. Oleh, Thanks for confirming, moving this BZ to verified. 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 (Important: Satellite 6.12 Release), 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-2022:8506 |