Passing configurations from runLocally
to main process
#3685
-
Hey there, I am currently working on some kind of SSH hardening during deployment.
So before deployment is being started, I do have try {
$detectedProjectUser = run('whoami', [
'tty' => false,
'timeout' => 1,
]);
} catch (Throwable) {
$detectedProjectUser = null;
}
// All good
if ($projectUser === $detectedProjectUser) {
set('remote-authenticated', get('remote-authenticated', true)); // only restore value in case something is already persisted, this should keep `false` once set
return;
}
// Detected user seems to vary from what we expect
if ($detectedProjectUser !== null) {
throw new RuntimeException(sprintf(
'SSH connection established but invalid user detected: %s',
$detectedProjectUser,
));
}
set('remote-authenticated', false); The "detected project user" is then compare against our expectation and if the value is Then there is should be skipped once $token = retrieve_token();
set('TOTP_TOKEN', $token); After if (get('remote-authenticated') === true) {
writeln('Connection(s) successfully initiaized.');
return;
}
throw new RuntimeException('Unable to initialize connection(s).'); However, my main problem is, that I am unable to pass the retrieved With v6, there were local tasks which were executed on the host and thus passing these kind of variables worked quite well. Is there any way how I can actually pass my variable from one of the tasks to another task or how I can make the whole "auth*" stuff running only on local machine? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 16 replies
-
You can use host configuration for this. Use |
Beta Was this translation helpful? Give feedback.
Just do
The callback is executed in the context of each hosts so in this example the
set
is applied to all selected hosts.