Parallel execution in the highstate?

370 views
Skip to first unread message

sfresher

unread,
Mar 14, 2016, 7:00:35 PM3/14/16
to Salt-users
Let's say I have a highstate that basically deploy and configure 10 aws instances, in exactly the same way.  Looks like state executions are in serial order.  Is there anyway to do executions in parallel?




Daniel Wallace

unread,
Mar 14, 2016, 7:20:45 PM3/14/16
to salt-...@googlegroups.com
you could use a map, and use the cloud runner via salt-run (you could also use the saltutil.runner module to run it via the minion on the master)


I build my whole map out using the saltutil.runner module on the salt* minion, which is on my master.

If you are ok without using a state or orchestrate runner to do this, you could just use salt-cloud with the -P flag to run in parallel.

It does not appear that the cloud execution module is able to run in parallel.

--
Daniel Wallace
@gtmanfred

On Mar 14, 2016, at 5:00 PM, sfresher <fei2...@gmail.com> wrote:

Let's say I have a highstate that basically deploy and configure 10 aws instances, in exactly the same way.  Looks like state executions are in serial order.  Is there anyway to do executions in parallel?





--
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.
For more options, visit https://groups.google.com/d/optout.

sfresher

unread,
Mar 14, 2016, 8:13:01 PM3/14/16
to Salt-users
This is great, Daniel.

However, I think using map with cloud_run requires predefined cloud profile.  I really wish something more dynamical, like the cloud execution module.

Daniel Wallace

unread,
Mar 15, 2016, 10:22:48 AM3/15/16
to salt-...@googlegroups.com
Unfortunately, looking through the CloudClient and Map classes in salt/cloud/__init__.py, the only place it looks like you can directly use the parallel=True
is in the map_run.

I don’t see a direct way to make it usable with and be able to configure stuff, even with the salt-run cloud.action create_multiprocessing, because action only allows you
to set the provider or instances, but not both.

The best bet to get it to work is to import salt.cloud and manage the Map on your own, and create the correct dmap data to be used in the run_map function


Here is where it would launch the multiprocessing pool.  https://github.com/saltstack/salt/blob/develop/salt/cloud/__init__.py#L2202

--
Daniel Wallace
@gtmanfred

Pratik Bandarkar

unread,
Jun 20, 2017, 5:35:33 AM6/20/17
to Salt-users
I am facing similar issue but in my scenario, its not aws instances. I have created top file with multiple targets and state files. For 9 target, salt takes approx 45 minutes. To me it do not look parallel execution. Did you find any solution for this issue? 

Seth House

unread,
Jun 20, 2017, 3:01:29 PM6/20/17
to salt users list
There are a few different issues being discussed in this thread, so it
would be useful to differentiate them to make sure everyone is on the
same page:

* Spinning up cloud VMs in parallel.
* Executing multiple state runs in parallel on a single host.
* Executing individual states within a state run concurrently on a single host.
* Executing a single state run on multiple hosts in parallel.

salt-cloud can create VMs in parallel via the CLI but that isn't
currently exposed by the cloud execution/runner/state modules. That
should be added to Salt.

Executing multiple state runs in parallel on a single host (like on
the Master as part of an Orchestrate run) is a useful addition and
there is an open pull request that will add that to a future Salt
release: https://github.com/saltstack/salt/pull/39670

Executing individual states concurrently within a single state run is
a flag to `state.highstate` / `state.sls` but is usually a bad idea
and should be used with care.

Executing a state run on multiple Minions at once is regular Salt
behavior. Whenever you run `salt '<tgt>' <module>.<fun>` from the CLI
all the Minions that match <tgt> get the broadcast at the same time
and will execute it independently.

Pratik, it sounds like that last one is what you are describing. Are
you running `salt '*' state.highstate` (or `state.apply`) to start the
state run? If so, take a look at the `Duration` field in the returns
for that run to see where all that time is being spent. If that isn't
it, please describe what you are running and what you are seeing.
(Maybe start a new thread.)
Reply all
Reply to author
Forward
0 new messages