reyi
reyi

Reputation: 1

Run a salt state from one salt minion on another minion

I want to run the following salt state from one minion onto another minion

restart_mysql_on_other_nodes:
  cmd.run:
    - name: service mysql restart

Is this possible? If yes, How do I do it?

I don't want to run the salt directly from master as there are some dependencies on the minion, post which the above salt must run.

Upvotes: 0

Views: 108

Answers (1)

Rahul Singh
Rahul Singh

Reputation: 41

If you want to run any command from one server to another it will be done via SSH but since you want to run Salt state it is not possible.

As you said you have dependencies on one minion post which you want to trigger Salt state to another server, that will be achieved using Salt orchestration

The most common use case of Salt orchestration is when we want to restart any webserver of services in different VMs we can use it.

Run stop ser1:
  salt.state:
    - tgt: azrlinvm1
    - sls:
      - lin.vm.service1stop

Run stop ser2:
  salt.state:
    - tgt: azrlinvm2
    - sls: 
      - lin.vm.service2stop
    - require:
      - Run stop ser1

Run pkgupdate:
  salt.state:
    - tgt: 'azrlinvm*'
    - sls: 
      - state.containing.pkgupdate
      - state.containing.toolsinstallation
      - some.other.useful.state
    - require:
      - Run stop ser2

Run start ser2:
  salt.state:
    - tgt: azrlinvm2
    - sls: 
      - lin.vm.service2start
    - require:
      - Run pkgupdate

Run start ser1:
  salt.state:
    - tgt: azrlinvm1
    - sls: 
      - lin.vm.service1start
    - require:
      - Run start ser2

Upvotes: 0

Related Questions