FAQ
Markus, I'm very sorry that I missed your replies here until now. Two quick
answers:

1. You may be best off adding a custom datestamp to the event data when you
send it that is already in the format you need. You could certainly massage
that in Jinja but I'm not sure the development-hours would be a good
trade-off there. ;-)

2. The minion id is available as {{ data.id }}.

I'm glad you were able to push through and get it working otherwise!
On Monday, April 6, 2015 at 3:04:11 PM UTC-6, Markus Kramer wrote:


Hi Seth,
I am very pleased with the reactor/orchestration setup and have two more
questions.

1) How to get the time of the event?

Looking at `salt-call -l debug` I found a time stamp

[DEBUG ] Sending event - data = {'pretag': None, '_stamp': '
*2015-04-06T19:31:19.696000*', 'tag': 'myco/external_task/status_update',
'data': {'__pub_pid': 6872, 'status': 'INFO', '__pub_fun': 'event.send',
'__pub_jid': '20150406213119696000', '__pub_tgt': 'salt-call'}, 'events':
None}



In the reactor file of your POC (process_status_updates.sls
<https://gist.github.com/whiteinge/b3c2ee46241e0512ef5b>), I therefore
added

process_status_updates:
runner.state.orchestrate:
- mods: orch.write_to_db
- pillar:
*tstamp: {{ data._stamp }}*
task: {{ data.data.task }}
status: {{ data.data.status }}


But tstamp was not the above Greenwich time with a "T" between date and
time, it was 2015-04-06 21:01:20+02:00, the local time on my master.
So I became unsure if this is a good idea and wanted to get a
recommendation from you.


2) How to get the minion name/id from the event?
I can add a key `minion` to the Pillar, but isn't this a workaround?


Best regards,
Markus

On Saturday, 4 April 2015 19:29:27 UTC+2, Seth House wrote:

Hi, Markus.

From the sound of things, using custom events plus the Salt Reactor is
your best bet. Since you want the data to end up in a database have
the Reactor call something that writes to the database, such as a
custom Runner module if you don't mind writing Python. That makes for
a very asynchronous workflow. Any relevant data you want to write to
the db should be included in the event data.

Be sure to include the --async flag in your initial call so the Salt
master doesn't block waiting for the return which could come hours
later, as you said:

salt --async Minion1 state.sls send_task1_to_minion

I was curious what this would look like as Reactor + Orchestrate so I
coded up a working POC below that writes to a sqlite db. There's no
reason you need to use Orchestrate for this, if you'd rather avoid
Python we already have a few execution modules for writing to
databases and they can be called from Orchestrate. If you're
comfortable with Python you could just as easily write and call a
custom Runner instead by replacing 'state.orchestrate' with
'yourcustomrunner.somefunction' in the Reactor file.

https://gist.github.com/whiteinge/b3c2ee46241e0512ef5b

There's not a lot of code there but there's a few concepts present
that aren't often seen in more common state runs. Let me know if you
have any questions.
--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 6 of 12 | next ›
Discussion Overview
groupsalt-users @
postedApr 4, '15 at 2:57p
activeMay 14, '15 at 4:23p
posts12
users3

People

Translate

site design / logo © 2022 Grokbase