support_kit/hosts/
host_control.rs1use crate::{DeploymentConfig, ShellCommand, SshError};
2
3use super::HostSession;
4
5pub struct HostControl;
6
7impl HostControl {
8 #[tracing::instrument(skip(deployment), level = "trace")]
9 pub async fn on_hosts(
10 deployment: &DeploymentConfig,
11 commands: Vec<ShellCommand>,
12 ) -> Result<(), SshError> {
13 tracing::trace!(
14 "executing on {num_hosts} hosts",
15 num_hosts = deployment.hosts.len()
16 );
17
18 for host in deployment.hosts.clone() {
19 tracing::trace!(host = ?host, "connecting to host");
20 let connection = HostSession::connect().host(host).call().await?;
21
22 for command in commands.clone() {
23 connection.run_cmd(command.command_and_args()).await?;
24 }
25 }
26
27 Ok(())
28 }
29}