saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Install Salt from the Salt package repositories here:
https://docs.saltproject.io/salt/install-guide/en/latest/
Apache License 2.0
14.23k stars 5.49k forks source link

Please add JID to Jinja Context #49890

Open grichmond-salt opened 6 years ago

grichmond-salt commented 6 years ago

Description of Issue/Question

The job id is not presently available via Jinja during state runs.

Note for starting point from @gtmanfred: https://github.com/saltstack/salt/blob/2018.3/salt/modules/state.py#L1053

Setup

N/A

Steps to Reproduce Issue

N/A

Versions Report

New request.

gtmanfred commented 6 years ago

Yeah, we should reasonably be able to pass the __pub_jid to the salt.utils.template.compile_template function so that the jid can be available in state files at the very least, then it can be passed to other templates using context.

eliasp commented 5 years ago

Isn't the JobID only available for non-local calls? So a salt-call --local state.apply foo would fail to render, as there's no JobID to be added to the Jinja context? So this would also effectively prevent local development of states outside a full-blown Minion/Master setup?

gtmanfred commented 5 years ago

the __pub_jid is the jid assigned from the master, so if you run --local, aka masterless, it will never hit the publish bus, and won't get the pub_jid.

gtmanfred commented 5 years ago

@saltstack/team-triage

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

stale[bot] commented 4 years ago

Thank you for updating this issue. It is no longer marked as stale.

jtraub91 commented 4 years ago

This feature would be very beneficial for a use case I'm working with. Consider a case where we log into a device and create a session. We could make the session name include the job id so that we have an easier time cross referencing the execution on the remote device with the job results, located on the minion / master

kajigga commented 4 years ago

I am working on a solution where we need like to correlate logs generated by salt and logs created by processes that are triggered by salt (perhaps via cmd.run or something like that).

It would be relatively easy to match up log entries if we could capture the jid and pass it to these sub processes where it could be included it in those generated logs.

dkfsalt commented 4 years ago

Having access to the JID would be useful for a use case of mine also

sagetherage commented 3 years ago

@waynew another good one for the Test Clinic, assigning you only in attempt to help write tests. We will still need tests written before we can commit to a release cycle for this issue and PR, but thank you all for your contributions!

achimmihca commented 2 years ago

Any news on this? I want to create a link in an email that points to the job in SaltGUI (for example: https://my.saltgui.com:3333/?id=20220316135831085312#job). Therefor, I need the JID.

amalaguti commented 10 months ago

Any news on this ?