Hassan Syed
Hassan Syed

Reputation: 20485

Salt state execution order

My top file looks like this.

base: 'G@roles:docker': - states/docker 'G@roles:sb-monolith-ecr': - states/aws-ecr-logged-in - states/sb-monolith-ecr 'G@roles:web-applications-ecr': - states/aws-ecr-logged-in - states/web-applications-ecr

The aws-ecr-loggin-in state:

aws-erc-logged-in: cmd.run: - name: $(aws ecr get-login --region={{ pillar['aws']['region'] }})

I am expecting the login state to trigger once and before the states that require the authentication to AWS ECR. Today when I refreshed my minions some of them had authentication errors. What is the best way to ensure the login command is run at the right time?

Upvotes: 0

Views: 810

Answers (1)

Mostafa Hussein
Mostafa Hussein

Reputation: 11940

I think it would be better if you used require to ensure that you logged in before any other state that needs authentication. also if there is an error in the login command any state that depends on it wont executed which will save you from getting authentication errors in this case. In your case you will need to require an SLS which called aws-ecr-logged-in What do you think ?

Upvotes: 1

Related Questions