문제

The Salt docs are full of this kind of pattern:

apache:
  pkg:
    - installed
  service:
    - running
    - require:
      - pkg: apache

This repetition ("install apache, now check whether apache was installed") seems to be a violation of don't-repeat-yourself (DRY). So is it necessary?

From "Understanding State Ordering":

To accomplish something similar to how classical imperative systems function all requisites can be omitted and the failhard option then set to True in the master configuration, this will stop all state runs at the first instance of a failure.

This seems to imply that the use of requisites everywhere is actually optional (assuming that the declaration order is correct) - but I'd like to know for sure.

도움이 되었습니까?

해결책

It is a remnant of the pre 0.15 days when states weren't executed top down.

Ordering is now sufficient.

다른 팁

States are now executed in the order they are declared in your sls files. Where you will still want to use "require" is if you want to ensure a certain state executes successfully before another.

For example, you may want to ensure a software package is installed correctly before attempting to lay down a config file.

apache:
  pkg:
    - installed
  file:
    - managed
    - name: /etc/apache/httpd.conf
    - source: salt://apache/httpd.conf
    - require:
      - pkg: apache

Without the "require" in the above example, the config file would be laid down even if the apache pkg failed to install.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top