Skip to content

Notification template export issue #184

@mnehrebecki

Description

@mnehrebecki

Summary

I’m using a notification template in Ansible Automation Platform (AAP) and Success message body looks like this:

{{ job_friendly_name }} #{{ job.id }} '{{ job.name }}' {{ job.status }}

Start: {{ job.started }}
End: {{ job.finished }}
Duration: {{ job.elapsed }} seconds

view details at {{ url }}

After using the filetree_create role, the generated YAML looks like provided in Actual Behavior.
However, it should look like provided in Desired Behaviour (only one !unsafe before the whole block):

So it seems the role is incorrectly inserting additional !unsafe tags inside the Jinja expressions.
This breaks the formatting of the template and causes unexpected rendering behavior in AAP.

Issue Type

  • Bug Report

Ansible, Collection, Controller details

It's happening on AAP 2.4 but the code of collection is the same as for AAP 2.5.

    messages:
{{ current_notification_templates_asset_value.messages | to_nice_yaml(indent=2, sort_keys=false) | indent(width=6, first=True) | regex_replace('(^[^:]*): (.*){([{%])', '\\g<1>: !unsafe \\g<2>{\\g<3>', multiline=True) | replace("body: '", "body: !unsafe \'") }}

OS / ENVIRONMENT

N/A

Desired Behavior

success:
        body: !unsafe '{{ job_friendly_name }} #{{ job.id }} ''{{ job.name }}'' {{ job.status }}


          Start:  {{ job.started }}

          End: {{ job.finished }}

          Duration: {{ job.elapsed }} seconds


          view details at {{ url }}'

Actual Behavior

success:
        body: !unsafe '{{ job_friendly_name }} #{{ job.id }} ''{{ job.name }}'' {{ job.status }}


          Start: !unsafe {{ job.started }}

          End: !unsafe {{ job.finished }}

          Duration: !unsafe {{ job.elapsed }} seconds


          view details at {{ url }}'

STEPS TO REPRODUCE

  1. Paste this code into notification template field Success message body
{{ job_friendly_name }} #{{ job.id }} '{{ job.name }}' {{ job.status }}

Start: {{ job.started }}
End: {{ job.finished }}
Duration: {{ job.elapsed }} seconds

view details at {{ url }}

  1. Run filetree_create to create export
  2. Run filetree_read with exported file

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions