How to call salt state asynchronously in salt orchestration

344 views
Skip to first unread message

rvairaashtak

unread,
Jul 31, 2018, 8:51:48 PM7/31/18
to Salt-users
Hi,

I have a scenario where salt state is going to do package updates on number of minions, the salt state itself takes 10-15 minutes to complete, I want to use this state inside the orchestrion and don't want to wait for the completion of state, what is the correct way of specifying the async option inside the salt orchestration,I couldn't find any example in the documentation so reached out here:

Here is my salt-orchestration:

patch_update.sls

Repo_Cheeck:
   salt.state:
     - tgt: minion1,minion2,minion3
     - tgt_type: list
     - sls:
         - repo_check 
             -- async

Patches_Update
   salt.state:
     - tgt: minion1,minion2,minion3
     - tgt_type: list
     - sls:
          - linux_patching
             -- async

Is there any documentation related to this?

Thanks.
RV


     

rvairaashtak

unread,
Aug 1, 2018, 6:40:21 PM8/1/18
to Salt-users
Reposting this, anyone has ever tried to call salt states in salt orchestration asynchronously? What is the correct syntax to pass the various arguments in Orchestration. I know how to pass the pillar data, but facing issues when passing the other parameters.

Matthew Phillips

unread,
Aug 1, 2018, 6:50:41 PM8/1/18
to salt-...@googlegroups.com
You can use 'parallel: true' like any other state if you're running 2018/latest. 

Cheers

--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/salt-users/e40ae480-8e15-4db6-9d1c-c7ea1889ba8b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Daniel Wallace

unread,
Aug 1, 2018, 7:24:12 PM8/1/18
to Salt-users
If you want to call them using async: True, it will be like passing `--async` from the commandline.

```
Repo_Check:
  salt.state:
    - tgt: minion1,minion2,minion3
    - tgt_type: list
    - sls:
      - repo_check 
    - async

Patches_Update
  salt.state:
    - tgt: minion1,minion2,minion3
    - tgt_type: list
    - sls:
      - linux_patching
    - async: true
```

But you should know that the state system does not allow you to run more than one state at a time on a minion, so the second one will fail saying there is already a state running on that minion.

You can either set `queue: True` to queue up the second state run on a minion, and it will wait for the first state to finish.

Or you can set concurrent: True if you are 100% certain that the different state runs will not conflict with each other.  If there is any overlap, it could cause weird behavior, like the fact that only one process of yum or apt can run at a time, so you can't update the repos and install updates at the same time.

Reply all
Reply to author
Forward
0 new messages