salt-projectremote-execution

how to run a shell script on remote using salt-ssh


my web server generates a shell script with more than 100 lines of code based on complex user selections. I need to orchestrate this over several machines using salt-ssh. what I need is to copy this shell script to remote and execute it from there for all devices. how to achieve this with salt-ssh ?. I can not install minions on the remote device.


Solution

  • Just as with normal minion. Write a state...

    add script:
        file.managed:
        - name: file.sh
        - source: /path/to/file.sh
    
    run script:
        cmd.run:
        - name: file.sh
    

    ...and apply it

    salt-ssh 'minions*' state.apply mystate.sls