Skip to content

Commit cf6c1e1

Browse files
Akm0dThomas Phipps
authored andcommitted
Added docs for pre-ssh-hook roster option
1 parent 5991f14 commit cf6c1e1

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

doc/topics/ssh/roster.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ The information which can be stored in a roster ``target`` is the following:
6161
# components. Defaults to /tmp/salt-<hash>.
6262
cmd_umask: # umask to enforce for the salt-call command. Should be in
6363
# 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
6467
ssh_pre_flight: # Path to a script that will run before all other salt-ssh
6568
# commands. Will only run the first time when the thin dir
6669
# 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:
7477
# Example: '$PATH:/usr/local/bin/'. Added in 3001 Release.
7578
ssh_options: # List of options (as 'option=argument') to pass to ssh.
7679
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.
7799

78100
.. _ssh_pre_flight:
79101

0 commit comments

Comments
 (0)