How to make one custom state dependent on another?

How to make one custom state dependent on another with props in the sls file?

Example: Two user states in the _states/seuss.py :

 # 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 depend on green_eggs :

 # init.sls have_green_eggs: seuss.green_eggs: - require: - user: seuss have_ham: seuss.ham: - require: - ??? 

How do I do ??? dependency on successful completion of green_eggs ?

+6
source share
1 answer

You need:

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

However, you are currently defining two states of the seuss resource, which means that either this seuss.ham or seuss.green_eggs called have_green_eggs can fulfill this requirement.

If you do not want this, you will need to define the states in separate files (for example, seuss_ham.exists and seuss_green_eggs.exists ).

+8
source

Source: https://habr.com/ru/post/944220/


All Articles