ansible-community / ara

ARA Records Ansible and makes it easier to understand and troubleshoot.
https://ara.recordsansible.org
GNU General Public License v3.0
1.86k stars 173 forks source link

Have a way to search with awx job-id in UI #273

Open kalyanbhonagiri16 opened 3 years ago

kalyanbhonagiri16 commented 3 years ago

What is the idea ?

1 Can we have a way to search playbook/results based on awx jobID, if it's integrated with AWX

2 Provide the awx jobID information in the results/Playbook API's

dmsimard commented 3 years ago

Hi @kalyanbhonagiri16 and thanks for the issue.

I don't have an AWX environment to test in right now. How is the jobID exposed ? Is it an environment variable ? A playbook variable ?

I see at least two options once you have the jobID: 1) Add it as a label to the playbook 2) Add it as a key/value attached to the playbook with ara_record

There is no action plugin for adding labels right now but I could see this being a use case for one.

Edit: I should have clarified but you can have labels like jobID:12345 which makes it possible to search for it afterwards, for example: https://demo.recordsansible.org/?label=python_version:3.5.10

With ara_record, you could record a key jobID and give it a value 12345 but there is no implementation for searching values, only keys. However, I figure it could be useful to have a link to the AWX job report (is it tied to the jobID ?), say if the URL is https://awx.example.org/job/<jobID> you could have that as a value of a record and set "link" as the type of the record.

dmsimard commented 3 years ago

https://docs.ansible.com/ansible-tower/latest/html/userguide/job_templates.html#launch-a-job-template seems to suggest that there is an awx_job_id variable available during the execution of playbooks:

Screenshot from 2021-05-05 09-56-59

With that in mind, I think we could come up with an action plugin to add a label to the playbook since the current ways of setting labels would not work unless someone has an idea.

kalyanbhonagiri16 commented 3 years ago

Thanks for the response @dmsimard . I have thought about passing the jobID as label but it wouldn't work as we wouldn't know awx_job_id before we trigger the playbook. I came up with a hack to pass awx_job_id to ara_label_name and i can search using that job_id . FYI, i'm using a workflow template in AWX , the first playbook will register the awx_job_id and will pass this to my second playbook(using ara_label_name) where it uses this job_id to search ARA