Home > Enterprise >  Saltstack: how to add infromational messages to long orchestration state
Saltstack: how to add infromational messages to long orchestration state

Time:11-20

i have some long saltstack orchestration states and i want to add some informational messages to it ( for example: Gonna apply some state on minion foo ) ,and this messages must be printed immediately( not after all actions completed ) .

Jinja log message ( {% do salt.log.error("Some message) %}) is not suitable ( they printed before state actually runs )

test.echo module also not suitable ( prints message after all actions completed )

test_blabla:
  salt.runner:
    - name: salt.cmd
    - arg:
      - test.echo
      - some_blabla

Is there any way to print messages during states execution ? May be i'm missing something ?

CodePudding user response:

There are ways to cheat. As long as you are talking about orchestration AND you are running said orchestration through salt-run.

And you almost had it. except to conflated the answer into jinja and the wrong module into the state. the reason the log message comes before anything runs is because you are calling it in jinja. but you don't have to call it through jinja. you can call it in a state.

test_blabla:
  module.run:
    - name: log.error
    - message: some_blabla

test_oh:
  salt.runner:
    - name: salt.cmd
    - arg:
      - test.sleep
      - 10

This is all kind of hacky as salt was not meant to do this. salt runs async which means it doesn't return until it is finished. or may not return directly at all and you are meant to check the results else where. another way to do this is have a state fire an event and watch the event bus instead of the state run.

  • Related