-
Bug
-
Resolution: Done
-
Normal
-
6.12.0
Description of problem:
The <%= @object.task.action_output %> option cannot be used as mentioned in "Katello Sync" webhook template.
Version-Release number of selected component (if applicable):
Satellite 6.12
Satellite 6.11
How reproducible:
Always
Steps to Reproduce:
1. Have a Satellite 6.12 built.
2. Import a manifest and enable any small repo
3. Enable shellhooks feature.
4. Create the following shellhook script inside /var/lib/foreman-proxy/shellhooks and make it executable
- cat print_objects
#!/bin/bash
cat > /tmp/results.txt
5. Satellite UI --> Administer --> Webhook templates --> Clone the "Katello Sync" template with "Katello Sync clone" name, uncomment all lines that have @object mentioned, and save it
6. Satellite UI --> Administer --> Webhook and create a new hook.
- hammer webhook info --id 2
Id: 2
Name: Test
Target URL: https://satellite.example.com:9090/shellhook/print_objects
Enabled: yes
Event: actions.katello.repository.sync_succeeded.event.foreman
HTTP Method: POST
HTTP Content Type: application/json
Webhook Template: Katello Sync clone
Created at: 2022/09/15 11:57:35
Updated at: 2022/09/15 12:12:49
7. Sync the repo while monitoring the production.log .
Actual results:
The sync will complete but the webhook execution will fail:
~~
2022-09-15T17:32:01 [E|dyn|67665294] Failed to run hook 'emit_event' for action 'Actions::Katello::Repository::Sync'
2022-09-15T17:32:01 [E|dyn|67665294] undefined method '#action_output' for ForemanTasks::Task::Jail (ForemanTasks::Task::DynflowTask) (Safemode::NoMethodError)
67665294 | /usr/share/gems/gems/safemode-1.3.6/lib/safemode/jail.rb:22:in `method_missing'
67665294 | Katello Sync clone:85:in `bind'
67665294 | /usr/share/gems/gems/safemode-1.3.6/lib/safemode.rb:51:in `eval'
67665294 | /usr/share/foreman/app/services/foreman/renderer/safe_mode_renderer.rb:7:in
~~
This happens as "task.action_output" is not a valid object for the repo sync tasks inside safe mode.
So removing the last line will allow the hook execution i.e.
~~
Task action output <%= @object.task.action_output %>
~~
and the results will be printed inside /tmp/results.txt file as expected.
Expected results:
Either remove the offending object entry from the default example template or else make it available to use.
Additional info:
If i use a different webhook template with following content:
<%= payload({
object: @object.task
}) %>
Followng task data gets printed:
{
"object":
,
and action_output is not one of them.