FAQ
Hello,


I would like to know if it is possible to 'capture' output in a state so I
can use it later in event data.

For example I got this state;

~~
update-packages:
   pkg.uptodate:
     - refresh: True

event-completed:
   event.send:
     - name: 'jwz/custom/maintenance/status'
     - data:
         status: 'completed'
     - require:
       - pkg: update-packages
~~

If I could capture the output from 'update-packages' I could use this in
the event.send state to report changed packages. I don't think this is
possible, but perhaps some jinja guru meditation(tm) can be applied.
Running cmd.run "yum update" etc. is an option but I like to keep it native
salt.

Any feedback welcome!
cDR





--
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

  • Colton Myers at Aug 24, 2015 at 7:14 pm
    You actually can, but you must write a custom state module.

    Within state modules, there is a special variable `__running__` which
    contains all of the results of previous states in the run. The output
    should be in there, ready for parsing.

    Hope that helps!

    --
    Colton Myers
    Core Engineer, SaltStack
    @basepi on Twitter/Github/IRC
    On Wed, Aug 19, 2015 at 6:45 AM, saltycdr wrote:

    Hello,


    I would like to know if it is possible to 'capture' output in a state so I
    can use it later in event data.

    For example I got this state;

    ~~
    update-packages:
    pkg.uptodate:
    - refresh: True

    event-completed:
    event.send:
    - name: 'jwz/custom/maintenance/status'
    - data:
    status: 'completed'
    - require:
    - pkg: update-packages
    ~~

    If I could capture the output from 'update-packages' I could use this in
    the event.send state to report changed packages. I don't think this is
    possible, but perhaps some jinja guru meditation(tm) can be applied.
    Running cmd.run "yum update" etc. is an option but I like to keep it native
    salt.

    Any feedback welcome!
    cDR





    --
    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.
    --
    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.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupsalt-users @
postedAug 19, '15 at 12:45p
activeAug 24, '15 at 7:14p
posts2
users2

2 users in discussion

Colton Myers: 1 post Saltycdr: 1 post

People

Translate

site design / logo © 2022 Grokbase