Ordered states, full conditional support for `unless`/`onlyif`
Its difficult to develop salt states due to the require/watch mechanisms.
I'd really like to have a "state" composed instead of ordered states.
say...
nginx:
ordered:
- pkg.installed
- file.directory:
- name: /etc/nginx/certs
- service.running
Another helpful addition would be the ability to simply require a whole state name as well as allow full conditionals in the require/watch/unless style clauses.
source:
git.latest:
....
deploy:
cmd.wait:
- name: deploy.sh
- condition: {% state['source'] and not mydeployment_exists() %}
The two things above would take 90% of the pain away from currently developing salt states
You can effectively require whole states using the overstate system: http://docs.saltstack.com/ref/states/overstate.html
Conditionals would definitely be convenient. There's an open issue for adding unless and onlyif as global state features, like require, and that will help a lot.
I think @thatch45 has been working on a simple mode where states are executed in the order defined which will help with your first one. Don't know the timeline on that feature, though.
Thanks for the requests!
I don't think unless/onlyif will do it. Consider the case of a git -> build -> deploy scenario.
I really want to be able to do a series of ordered operations in this case.
- git
- build
- stop services
- deploy
- configure using file template
- start services
Right now this takes about 200 lines of sls because I don't have ordering, debugging it is a nightmare, and if something goes wrong at any step there's no easy way to correct the sls file and try again where things left off.
I hope this helps understand the problem.
If I simply had ordering like in some other config management tools this would be ridiculously simple, and problems would not cause whole situations to fail and never be run again.
I think your best bet in this particular instance is to wait for @thatch45 to implement the simple ordering mechanism. Salt is very powerful in its ordering, but it does add a layer of initial complexity.
@bfrog, Yeah, we're building explicit ordering right now. I'll let you know when it's finished.
I'd love to see this too, in certain places I'm reverting to calling shell scripts from salt, because it results in a five-fold decrease in LOC, and no less readability/idempotence.
I think he finished up explicit ordering. It will be in 0.17. =)
I think this one's pretty much OK now :1st_place_medal:
Oh my gosh yes