failhard.rst 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. ======================
  2. Failhard Global Option
  3. ======================
  4. Normally, when a state fails Salt continues to execute the remainder of the
  5. defined states and will only refuse to execute states that require the failed
  6. state.
  7. But the situation may exist, where you would want all state execution to stop
  8. if a single state execution fails. The capability to do this is called
  9. ``failing hard``.
  10. .. _state-level-failhard:
  11. State Level Failhard
  12. ====================
  13. A single state can have a failhard set, this means that if this individual
  14. state fails that all state execution will immediately stop. This is a great
  15. thing to do if there is a state that sets up a critical config file and
  16. setting a require for each state that reads the config would be cumbersome.
  17. A good example of this would be setting up a package manager early on:
  18. .. code-block:: yaml
  19. /etc/yum.repos.d/company.repo:
  20. file.managed:
  21. - source: salt://company/yumrepo.conf
  22. - user: root
  23. - group: root
  24. - mode: 644
  25. - order: 1
  26. - failhard: True
  27. In this situation, the yum repo is going to be configured before other states,
  28. and if it fails to lay down the config file, than no other states will be
  29. executed.
  30. It is possible to override a Global Failhard (see below) by explicitly setting
  31. it to ``False`` in the state.
  32. .. _global-failhard:
  33. Global Failhard
  34. ===============
  35. It may be desired to have failhard be applied to every state that is executed,
  36. if this is the case, then failhard can be set in the master configuration
  37. file. Setting failhard in the master configuration file will result in failing
  38. hard when any minion gathering states from the master have a state fail.
  39. This is NOT the default behavior, normally Salt will only fail states that
  40. require a failed state.
  41. Using the global failhard is generally not recommended, since it can result
  42. in states not being executed or even checked. It can also be confusing to
  43. see states failhard if an admin is not actively aware that the failhard has
  44. been set.
  45. To use the global failhard set :conf_master:`failhard` to ``True`` in the
  46. master configuration file.