I need to change two hosts:

  • A new web-server gets configured
  • A tunnel between tunnel-host and the new web-server should get created

We implemented both, and both steps work:

root@s# salt-ssh webserver-new state.sls webserver
root@s# salt-ssh tunnel-host state.sls tunnel

How to do this with salt-ssh?

Hosts of above example:

  • s: the "master". It is not a salt-master, since we only use salt-ssh
  • webserver-new: This host was configured for the first time with salt
  • tunnel-host: This host creates some network tunnels which are needed for the new webserver.
  • Please elaborate instead of down-voting: What's wrong with this question? – guettli May 17 '18 at 6:58
  • Likely because there's not really a problem you're asking for answers regarding, but rather you're asking how to use salt-ssh with little to no information as to what issues you actually may be running into. If you have a specific issue, please post details on that so people can contribute to solve a problem; otherwise, you're attempting to invoke a meatware man page. – Spooler May 18 '18 at 17:05
  • Which one is the master and which ones are the minions? Did you fill out the roster? – Leo May 21 '18 at 23:42
  • @Leo I added a list of all involved hosts. – guettli May 22 '18 at 9:07
  • @Spooler yes, you are right there is no specific issue. This is a general question about the way how to use salt-ssh if you want to change several hosts. – guettli May 22 '18 at 9:08

You should create a top file:

    - webserver
    - tunnel

and execute highstate on all hosts:

salt-ssh '*' state.apply

More advanced alternative would be to use orchestration with ssh=true option, especially when states on different hosts depend on each other, but it requires a Salt master (even for salt-ssh minions).

# /srv/salt/orch/webserver.sls
    - tgt: 'webserver-new'
    - ssh: true
    - sls:
      - webserver
    - tgt: 'tunnel-host'
    - ssh: true
    - sls:
      - tunnel
    - require:
      - salt: setup_webserver

And execute it with salt-run state.orchestrate orch.webserver

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.