Last active
May 26, 2023 19:25
-
-
Save trebortech/9966c0d3fc5f45945819d9c0511b8976 to your computer and use it in GitHub Desktop.
salt-ssh example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
reactor: | |
- 'ssh/test': | |
- /srv/reactors/ssh_test.sls |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ssh_user: salt | |
ssh_passwd: ***** | |
raw_shell: True | |
ignore_host_keys: True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% if data['data']['hostid'] is defined %} | |
{% set hostid = data['data']['hostid'] %} | |
'Send ssh command': | |
runner.state.orchestrate: | |
- mods: orch.stats | |
- pillar: | |
hostid: {{ hostid }} | |
{% endif %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% 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