Assistance with Ansible Facts in Playbook Role

Hi,
I’m working on an Ansible playbook and trying to use an Ansible fact as a variable within a role. Specifically, I’m trying to replace the owner_name fact with the corresponding value in my playbook.

Here’s the code snippet where I’m encountering the issue:

yaml

Copy code

rescue:
  - name: Sending an email on failure of tasks
    community.general.mail:
      host: sdl-smtp.blabla.loc
      port: 25
      from: "foreman_pipline@blabla"
      to:
        - "{{ owner_name }}"

Unfortunately, I’m having trouble making this work within the role, and the variable owner_name is not being recognized as expected. I would greatly appreciate any guidance or assistance you could provide on how to properly reference this Ansible fact in the role.

P.S
this is the error
"The task includes an option with an undefined variable. The error was: ‘owner_name’ is undefined. ‘owner_name’

Thank you in advance for your help!

Best regards,
Shay

owner_name is coming from ansible roles of foreman so how can use it

just a guess

try
foreman.owner_name