Question about cmd.wait example in docs

272 views
Skip to first unread message

Scott Edwards

unread,
Aug 7, 2015, 3:45:24 PM8/7/15
to Salt-users
In the following example from the documentation, why do they use cmd.wait vs cmd.wait_script? I'm trying to make sure I understand when I should execute scripts with cmd.run, cmd.script and cmd.wait_script. To me this following example should have used cmd.wait_script.


SHOULD I USE CMD.RUN OR CMD.WAIT?

These two states are often confused. The important thing to remember about them is that cmd.run states are run each time the SLS file that contains them is applied. If it is more desirable to have a command that only runs after some other state changes, then cmd.wait does just that. cmd.wait is designed to watch other states, and is executed when the state it is watching changes. Example:

/usr/local/bin/postinstall.sh:
  cmd.wait:
    - watch:
      - pkg: mycustompkg
  file.managed:
    - source: salt://utils/scripts/postinstall.sh

mycustompkg:
  pkg.installed:
    - require:
      - file: /usr/local/bin/postinstall.sh

Colton Myers

unread,
Aug 18, 2015, 2:11:51 PM8/18/15
to salt-...@googlegroups.com
Agreed, that is a poor example. Could you file an issue so we can get that cleared up?

As a side note, these days I don't think anyone should be using `cmd.wait` or `cmd.wait_script` at all. With the introduction of the new `onchanges` requisite, we no longer need those functions. They were designed to use the `watch` requisite to imitate what the new `onchanges` requisite does automatically.

--
Colton Myers
Core Engineer, SaltStack
@basepi on Twitter/Github/IRC

--
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+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages