I have an SLS file in SaltStack Orchestrator which contains something like this:
Plan A:
salt.state:
- tgt: my-server
- sls: service-a
Plan B:
salt.state:
- tgt: my-server
- sls: service-a
- onfail:
- Plan A
And inside service-a SLS file I have something like this:
{% set image = pillar["image"] | default("service-api") %}
{% set version = pillar["version"] %}
Deploy A:
cmd.run:
- name: docker-compose -f {{version}}/docker-compose.yml up
..... (+ many lines of other commands and codes)
Now, the problem is, when Plan A failed, then Plan B should do the rollback, but it does the same and fails again because I didn't change the version variable inside the service-a SLS file. I want to change the version variable inside the service-a SLS file via the Orchestrator file. For example, when it goes to Plan B then it should change the version to old.
The only way I know is it can be handled by Python modules, but as far as possible I wanna address it by SLS files.