0

I would like to disable cron on the minion when salt gets executed.

Disabling it would be easy: service.disabled

But how to enable it again (in all cases (success or error))?

What I want is comparable with a context-manager in the python programming language.

guettli
  • 3,113
  • 14
  • 59
  • 110

1 Answers1

1

All states are executed, even when some failed, if they do not require a failed one. So you could start with a service.dead, some other states, then a service.running at the end.

I don't understand why you would want that, though.

Christophe Drevet
  • 1,962
  • 2
  • 17
  • 25
  • AFAIK `failhard` does brake this. If a failhard state fails, then no other states get executed. But I am unsure. Maybe I am wrong: https://docs.saltstack.com/en/latest/ref/states/failhard.html#state-level-failhard – guettli Sep 24 '18 at 11:22
  • Yes, that's the purpose of failhard, indeed. – Christophe Drevet Sep 24 '18 at 15:10
  • I understand the need because we have the same with apticron when running integration tests. Sometimes, during tests, apticron run and this make highstate fail (because /var/cache/apt locked). So we configure apticron to never run when running tests. – daks Jan 17 '19 at 15:10