#check #script #automation #configuration #action #system #instructions

pass_tool

Tool for system configuration intended for making automation scripts using Rust

5 unstable releases

0.3.4 Nov 13, 2023
0.3.1 Nov 9, 2023
0.3.0 Nov 9, 2023
0.2.0 Nov 8, 2023
0.1.0 Oct 11, 2023

#397 in Configuration

Download history 14/week @ 2024-02-19 19/week @ 2024-02-26 2/week @ 2024-03-11 52/week @ 2024-04-01

54 downloads per month

MIT license

86KB
2.5K SLoC

Pass

docs / crate

Pass - is a tool for system configuration. Configuration change is described as checks and actions. Check is for checking current state of system (eg. if nginx installed). Action changes state of the system (eg. install nginx). Pass allows either apply changes or verify if changes can be applied based on described checks.

How to use

Checks and Actions are organized into Instructions, and list of Instructions is making Playbook.

Check - only checks current state of system, doesn't change anything, it is just true/false flag

Action - changes system settings, can fail

Playbook - contains environment checks and list of instructions. Environment checks checked before any of instructions is performed.

Instruction - contains environment checks, confirmation checks and action to be applied:

  • Environment checks checked before action, and must be all true
  • Confirmation checks checked before and after action, if it false before action - action will be applied and confirmation checks checked again after action now all checks must be true, if it true before action - action will be skipped (action considered already applied)

Example

Here is "Hello, World!" example:

use pass_tool::{actions::write_file, checks::is_file, instruction, run_cli, Playbook};

fn main() {
    let file_path = "pass-example__hello_world.txt";
    let playbook = Playbook::new(
        "Hello world",
        "This example creates file with \"Hello, world!\" text, if file already exists it will do nothing",
        [],
        [instruction(write_file(file_path, "Hello, world!")).confirm(is_file(file_path))],
    );
    run_cli(playbook, include_str!("hello_world.rs"));
}

Another example available in examples/ folder is https_webserver, it will configure nginx with https support using letsencrypt certificate.

More links

Also I'm making note taking and todo list app https://heaplist.app/

Dependencies

~4–15MB
~182K SLoC