diff --git a/Cargo.lock b/Cargo.lock index f2716a5..62342e9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -608,7 +608,7 @@ dependencies = [ [[package]] name = "zap-cli" -version = "0.1.0" +version = "0.1.1" dependencies = [ "colored", "gumdrop", @@ -624,7 +624,7 @@ dependencies = [ [[package]] name = "zap-model" -version = "0.1.0" +version = "0.1.1" dependencies = [ "handlebars", "log", diff --git a/README.adoc b/README.adoc index cf8c782..d2175d7 100644 --- a/README.adoc +++ b/README.adoc @@ -56,6 +56,19 @@ Once this has been set up, you can run: zap plan hello.zplan -t alpha --dry-run ---- +== Command Line + +The `zap` command line interface has a number of subcommands that can help with +the development and deployment of tasks and plans. + +=== cmd + +=== check + +=== plan + +=== task + == Examples diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 1452f08..b697117 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zap-cli" -version = "0.1.0" +version = "0.1.1" authors = ["R. Tyler Croy "] edition = "2018" description = "A simple configuration management and orchestration tool" diff --git a/cli/src/transport/mod.rs b/cli/src/transport/mod.rs index 32b6f09..42c09d5 100644 --- a/cli/src/transport/mod.rs +++ b/cli/src/transport/mod.rs @@ -10,6 +10,7 @@ pub mod ssh; */ pub trait Transport { fn connect(&mut self, target: &Target) -> bool; + fn disconnect(&mut self); fn run_group( &mut self, cmd: &ExecutableTask, diff --git a/cli/src/transport/ssh.rs b/cli/src/transport/ssh.rs index 2cd61d7..4cd8ca3 100644 --- a/cli/src/transport/ssh.rs +++ b/cli/src/transport/ssh.rs @@ -40,18 +40,31 @@ impl Transport for Ssh { // XXX: This is inefficient for target in inventory.targets.iter() { if &target.name == target_name { - println!("Running on `{}`", target.name); + println!("Running on `{}` {}", target.name, target.uri); status = self.run(command, &target, dry_run); + self.disconnect(); } } } status } + fn disconnect(&mut self) { + debug!("Disconnecting"); + if self.connected { + self.session.disconnect(None, "Zappidy doo-da", None); + // There doesn't seem to be any cleaner way to close other than + //.just dropping the session + self.session = Session::new().unwrap(); + } + self.connected = false; + } + fn connect(&mut self, target: &Target) -> bool { if self.connected { return self.connected; } + debug!("Connecting to {}", target.uri); let tcp = TcpStream::connect(format!("{}:22", target.uri)).unwrap(); self.session.set_tcp_stream(tcp); self.session.handshake().unwrap(); diff --git a/inventory.yml b/inventory.yml index 0ee64da..969e98b 100644 --- a/inventory.yml +++ b/inventory.yml @@ -8,7 +8,7 @@ targets: - name: freebsd-tor uri: 192.168.1.41 - name: gopher - uri: 192.168.1.41 + uri: 192.168.1.42 - name: zap-freebsd uri: 192.168.1.224 config: diff --git a/model/Cargo.toml b/model/Cargo.toml index d7533f8..21bb9e6 100644 --- a/model/Cargo.toml +++ b/model/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zap-model" -version = "0.1.0" +version = "0.1.1" authors = ["R. Tyler Croy "] edition = "2018" description = "Internal models for zap, a simple configuration management tool"