문제

How do I make one custom state dependent on another with a requisite in an sls file?

Example: Two custom states in a _states/seuss.py module:

# seuss.py
def green_eggs():
    return {'name': 'green_eggs', 'result': True, 'comment': '', 'changes': {}}

def ham():
    return {'name': 'ham', 'result': True, 'comment': '', 'changes': {}}

I want ham to be dependent on green_eggs:

# init.sls

have_green_eggs:
  seuss.green_eggs:
  - require:
    - user: seuss

have_ham:
  seuss.ham:
  - require:
    - ???

How do I make ??? a dependency on the successful completion of green_eggs?

도움이 되었습니까?

해결책

You would want:

have_ham:
  seuss.ham:
    - require:
      - seuss: have_green_eggs

However, you are currently defining two states of a seuss resource, which means that either a seuss.ham or a seuss.green_eggs called have_green_eggs could fulfil that requirement.

If you don't want that, then you will have to define the states in separate files (e.g. seuss_ham.exists and seuss_green_eggs.exists).

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