Commit Graph

26 Commits

Author SHA1 Message Date
R Tyler Croy eac957569c Upgrade dependencies 2021-05-23 11:50:50 -07:00
R Tyler Croy 4888aa9ecf Make the .ztask suffix not required when loading in the zplan
Fixes #3
2021-01-01 14:41:42 -08:00
R Tyler Croy 50ab1a5b14 Restructuring the file tree to make it easier to start adding "native tasks"
Some number of tasks I will want to be "builtin" and need to know a little bit
more about the transport in order to make that work.

The traits, they are coming.

See #1
2021-01-01 14:32:51 -08:00
R Tyler Croy 6e0c76dd70 Add disconnect to the Transport trait to allow groups to be properly run
Since I refactored a Transport to allow for maintaining a connection, subsequent
commands were being run on the same target. This ensures that when a group is
being run, that the session is flushed between connections
2021-01-01 11:13:07 -08:00
R Tyler Croy 56683f2288 Rename the zap-cli package to allow for publishing to crates.io 2021-01-01 10:25:27 -08:00
R Tyler Croy 40ae75bff1 Add necessary details to publish to crates.io 2021-01-01 10:19:22 -08:00
R Tyler Croy 872157ce98 Move the ExecutableTask to the root of zap-models 2021-01-01 10:14:58 -08:00
R Tyler Croy a3accf213a Refactor the parser package into a "model" package which is more accurate
Most of its job is to contain the models for different data structures
2021-01-01 10:10:01 -08:00
R Tyler Croy d605bc4229 Support the `unless` parameter on a task to run a little script for idempotency 2020-12-31 22:42:23 -08:00
R Tyler Croy bc4396a0de Refactor the SSH transport to make it easy to re-send files
This also has some refactor to ensure that a set up transport stays connected
instead of reconnecting for each "run"
2020-12-31 21:53:19 -08:00
R Tyler Croy 7e3d7fb5ad Add a --dry-run argument to plan/task so that you can see what scripts will be run 2020-12-31 15:38:14 -08:00
R Tyler Croy 184d455b2d Add the `check` command to check the validity of zplan and ztask files 2020-12-31 15:24:55 -08:00
R Tyler Croy b35801a609 Support the provides parameter to allow tasks to have some level of idempotency 2020-12-31 14:37:48 -08:00
R Tyler Croy d765cc5703 Support invoking a task with a file-based script via an args file
Basically the first parameter to the invoked task-file will be an args-file of
JSON-encoded parameters and values.

    ./my-special-script ._zap_args
2020-12-31 14:20:07 -08:00
R Tyler Croy eda6f523a3 Major refactor to cleanly run tasks from files or inline
ExecutableTask needs to find a new home, and some other things still need to get
shuffled around. This commit does however copy a temp file over for execution
which seems to be the best possible scenario for safe execution

An example run:

❯ RUST_LOG=debug ./target/debug/zap task tasks/shell/bash.ztask -p "script=set -xe; pwd" -t zap-freebsd
Running task with: TaskOpts { task: "tasks/shell/bash.ztask", parameter: ["script=set -xe; pwd"], targets: "zap-freebsd" }
 INFO  zap > Task located, preparing to execute
 DEBUG handlebars::render > Rendering value: Path(Relative(([Named("script")], "script")))
 DEBUG handlebars::context > Accessing context value: AbsolutePath(["script"])
err: + pwd
/root
2020-12-31 13:48:07 -08:00
R Tyler Croy fbde2ed863 Implement the execution of plans via the CLI 2020-12-31 11:10:12 -08:00
R Tyler Croy 8981370222 Refactoring the parsing code a fair bit to make way for the zplan parser
Turns out that a single module using #[derive(Parser)] cannot have two parsers
in the same module
2020-12-31 09:48:39 -08:00
R Tyler Croy a7efcc6085 Switch ztasks to be file-based
Played around with using symbols, and figuring out the namespacing is going to
be too much of a pain in the ass
2020-12-31 09:30:04 -08:00
R Tyler Croy ff3f3c5263 Move away from environment variables and switch to rendering scripts as handlebars
This will make sure there's a better cross-platform approach for getting
parameters into these commands.
2020-12-31 09:20:22 -08:00
R Tyler Croy 754fd428f8 Allow passing some configuration for user/password on SSH
With some real integration testing it looks like the "set an environment
variable" approach is not really going to work effectively.

I think the script {} will need to be treated like a template instead, since
different shells require different ways of setting env variables and it doesn't
appear that there's a good ssh2-based way to set these environment variables.
2020-12-30 22:46:29 -08:00
R Tyler Croy 7b9066d096 Implement the simple support for running a task
This includes an echo task for funsies
2020-12-30 21:11:35 -08:00
R Tyler Croy 904bf007ce Start working on the task definition parsing grammar, pretty easy. 2020-12-30 14:27:33 -08:00
R Tyler Croy 0bdd2ba9bc Add some sketches of what tasks and plans might look like 2020-12-29 22:16:52 -08:00
R Tyler Croy 822eceb0d6 Refactor some code to make the Ssh a "transport"
I'm still not thrilled with the need to hard-code some things here, and tried to
use the enum_dispatch crate to make the transport mapping go directly from
inventory::Transport to transport::Ssh. Didn't work because it needs to be
struct/tuple syntax
2020-12-29 16:50:01 -08:00
R Tyler Croy e82ca1eff0 Allow running commands across a group 2020-12-28 22:34:48 -08:00
R Tyler Croy b66d6824bc Play around with simple SSH commands 2020-12-28 22:12:45 -08:00