Atlas
Atlas

Reputation: 19

execute a function on master in saltstack salt .sls file and run on a minion

I'm planning to use the salt-cloud function to take a snapshot before applying a yum update patch.

the command that needs to be run on master is salt-cloud -a create_snapshot vmname snashot_name

I have a state sls file to run patching on target. Is it possible to have a mix of executing commands on both the target and the master?

Thanks.

Upvotes: 1

Views: 1902

Answers (1)

whytewolf
whytewolf

Reputation: 704

Yes you can. Using orchestration.

Which is a build of states that run against the master. telling the master what to do.

an example i normally give that does both run runner functions and salt remote execution functions is this update script https://github.com/whytewolf/salt-phase0-orch/blob/master/orch/sys/salt/update.sls that runs through a large series of commands to update both master and all minions into a ready state.

for your example you would use a salt.runner calling https://docs.saltproject.io/en/latest/ref/runners/all/salt.runners.cloud.html#salt.runners.cloud.action followed by salt.state to call the state that runs the patching.

more about orchestration

Upvotes: 1

Related Questions