Model HN: Tricorder – Automation the KISS manner, no YAML alive to, written in Rust

65

My gracious professor says this plugin is terribly cute!!

tricorder






First a listing

[[hosts]]
identity="backend"
address="10.0.1.10: 22"
user="root"
tags=["server", "backend", "myapp"]
vars={ msg="hi" }

Then a say

$ tricorder -i /direction/to/inventory kind -- echo "{host.identity} says {host.vars.msg}"

In the end, a JSON output

[
  {
    "host": "backend",
    "success": true,
    "info": {
      "exit_code": 0,
      "stdout": "backend says hin",
      "stderr": ""
    }
  }
]

Add dependency

Write your recipe

First, import symbols

spend tricorder::prelude:: *;
spend tricorder::responsibilities::exec;
spend serde_json::json;

Then, fabricate your inventory

let inventory = Inventory::unique()
  .add_host(
    Host::unique(Host::identity("localhost").unwrap(), "localhost: 22".to_string())
      .set_user("root".to_string())
      .add_tag(Host::heed("local").unwrap())
      .set_var("msg".to_string(), json!("hi there"))
      .to_owned()
  )
  .to_owned();

In the end, speed your responsibilities

let process = exec::Assignment::unique("echo "{host.identity} says {host.vars.msg}"".to_string());

Sequentially:

let consequence = inventory.hosts.run_task_seq(&process).unwrap();

Or concurrently:

let consequence = inventory.hosts.run_task_parallel(&process).unwrap();

The final consequence is a serde_json::Charge:

Bear and speed

Actor George Takei autographs a tricorder

Ansible is a astronomical diagram for automation. On the opposite hand it suffers
from the an identical thunder of many such tools: a gigantic pile of personalized YAML DSL.

YAML is outmoded to scheme a declarative syntax of your automatic workflow. Here is
wonderful for easy spend circumstances, but automation can change into moderately complex very
swiftly.

As soon as these tools launch imposing:

  • defend watch over drift structures (circumstances, loops)
  • variable assignations
  • modules
  • package administration
  • …

Your YAML details change steady into a programming language with bad developer
ride.

tricorder aims to repair this. It presents you a single diagram to compose responsibilities on
more than one remotes. You then spend your same old UNIX tools cherish bash, jq, curl,
etc… to fabricate these responsibilities collectively.

The title comes from Critical particular person Depart’s Tricorder,
a multifunction hand-held diagram to compose sensor environment scans, details
recording, and details diagnosis. Absolute most sensible mighty anything required by the map.

The main aim of tricorder is to scheme the basic tools to compose responsibilities on
faraway hosts and obtain out of your manner. Permitting you to combine it with any
scripting language or programming language of your selection, in map of forcing
you to invent in a sub-par personalized YAML DSL.

Spock stared arduous at his tricorder, as if by sheer will he might perchance probably power it to
show him the acknowledge to his questions.

Read More
Portion this on knowasiak.com to debate with folk on this matterRegister on Knowasiak.com now in the event you are now no longer registered yet.

Charlie Layers
WRITTEN BY

Charlie Layers

Fill your life with experiences so you always have a great story to tellBio: About: