Add a pre-connect hook

This can be used for hooks that should run before connecting to remote
hosts. An example use case is pre-warming DNS.
This commit is contained in:
Donal McBreen
2023-05-24 11:39:48 +01:00
parent 483b893018
commit 66f9ce0e90
8 changed files with 75 additions and 9 deletions

View File

@@ -76,6 +76,8 @@ module Mrsk::Cli
if MRSK.holding_lock?
yield
else
run_hook "pre-connect"
acquire_lock
begin
@@ -135,7 +137,7 @@ module Mrsk::Cli
if !options[:skip_hooks] && MRSK.hook.hook_exists?(hook)
say "Running the #{hook} hook...", :magenta
run_locally do
MRSK.with_verbosity(:debug) { execute *MRSK.hook.run(hook, **details) }
MRSK.with_verbosity(:debug) { execute *MRSK.hook.run(hook, **details, hosts: MRSK.hosts.join(",")) }
rescue SSHKit::Command::Failed
raise HookError.new("Hook `#{hook}` failed")
end