1

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.
guettli
  • 3,113
  • 14
  • 59
  • 110
  • Please elaborate instead of down-voting: What's wrong with this question? – guettli May 17 '18 at 06: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 09: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 09:08

1 Answers1

2

You should create a top file:

base:
  'webserver-new':
    - webserver
  'tunnel-host':
    - 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
setup_webserver:
  salt.state:
    - tgt: 'webserver-new'
    - ssh: true
    - sls:
      - webserver
create_tunnel:
  salt.state:
    - tgt: 'tunnel-host'
    - ssh: true
    - sls:
      - tunnel
    - require:
      - salt: setup_webserver

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

A. Z.
  • 96
  • 4