Run a salt state from one salt minion on another minion

34 views Asked by At

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.

1

There are 1 answers

0
Rahul Singh On

If you want to run any cmd 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.

Ex:

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