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
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With