You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/topics/ssh/roster.rst
+22Lines changed: 22 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -61,6 +61,9 @@ The information which can be stored in a roster ``target`` is the following:
61
61
# components. Defaults to /tmp/salt-<hash>.
62
62
cmd_umask: # umask to enforce for the salt-call command. Should be in
63
63
# octal (so for 0o077 in YAML you would do 0077, or 63)
64
+
ssh_pre_hook: # Path to a script that will run on the host before all other
65
+
# salt-ssh commands. Runs every time salt-ssh is run.
66
+
# Added in 3008 Release
64
67
ssh_pre_flight: # Path to a script that will run before all other salt-ssh
65
68
# commands. Will only run the first time when the thin dir
66
69
# does not exist, unless --pre-flight is passed to salt-ssh
@@ -74,6 +77,25 @@ The information which can be stored in a roster ``target`` is the following:
74
77
# Example: '$PATH:/usr/local/bin/'. Added in 3001 Release.
75
78
ssh_options: # List of options (as 'option=argument') to pass to ssh.
76
79
80
+
.. _ssh_pre_hook:
81
+
82
+
ssh_pre_hook
83
+
------------
84
+
85
+
Introduced in the 3008 release, the `ssh_pre_hook` is an option in the Salt-SSH roster that allows the execution of a script on the origin server before any SSH connection attempts are made.
86
+
This is particularly useful in environments where dynamic setup is required, such as signing SSH keys or configuring environment variables.
87
+
88
+
The `ssh_pre_hook` script is specified in the roster file for each target or globally using `roster_defaults`. It runs every time `salt-ssh` is invoked, ensuring that all prerequisites are met before making an SSH connection.
89
+
90
+
.. code-block:: yaml
91
+
92
+
test:
93
+
host: 257.25.17.66
94
+
ssh_pre_hook: /path/to/script param1 param2
95
+
96
+
If the script specified in `ssh_pre_hook` fails (returns a non-zero exit code), `salt-ssh` will halt further execution, preventing connection attempts to the target server.
97
+
98
+
Usage of `ssh_pre_hook` provides a flexible mechanism to perform necessary preparations and checks, ensuring that the environment conforms to required conditions before proceeding with SSH operations.
0 commit comments