Skip to content

Instantly share code, notes, and snippets.

@trebortech
Last active May 26, 2023 19:25
Show Gist options
  • Save trebortech/9966c0d3fc5f45945819d9c0511b8976 to your computer and use it in GitHub Desktop.
Save trebortech/9966c0d3fc5f45945819d9c0511b8976 to your computer and use it in GitHub Desktop.
salt-ssh example
The goal of this test was to build an orchestration file that can execute commands on a non-minion via salt-ssh.
<event> -> <reactor> -> <reactor sls> -> <orchestration file> -> <ssh commands>
Flow:
- salt-call event.send ssh/test '{"hostid": "minion-deb8-py2"}'
- event is dropped on the eventbus with a hostid to target commands
- reactor file triggers orchestration
master.d files
- ssh.conf
- reactor.conf
/srv/salt/orch
- ssh.sls
/srv/reactors
- ssh_test.sls
NOTE:
- A roster file is required but it can be empty
- hostid provided must resolve
reactor:
- 'ssh/test':
- /srv/reactors/ssh_test.sls
ssh_user: salt
ssh_passwd: *****
raw_shell: True
ignore_host_keys: True
{% if data['data']['hostid'] is defined %}
{% set hostid = data['data']['hostid'] %}
'Send ssh command':
runner.state.orchestrate:
- mods: orch.stats
- pillar:
hostid: {{ hostid }}
{% endif %}
{% set hostid = 'minion-deb9-py2' %}
"SSH Test":
salt.runner:
- name: ssh.cmd
- tgt: {{ hostid }}
- kwarg:
fun: "ls /"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment