snelling/maestro

Simple IT automation tool

0.1.0 2017-03-23 03:03 UTC

This package is auto-updated.

Last update: 2024-09-09 06:03:47 UTC


README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

Maestro is a simple IT automation tool to run bash scripts against local or remote servers. It will automatically pipe all output from any script run into your terminal.

KRAMER: You know you hurt the Maestro's feelings.

JERRY: Oh what, because I didn't call him Maestro?

KRAMER: That's right.

JERRY: Ya know I feel a little funny calling somebody Maestro.

KRAMER: Why?

JERRY: Because it's a stupid thing to be called.

Install

Via Composer

composer global require snelling/maestro

This is still a work in progress, and probably will need to be installed by hand until I have officially tagged this repository.

Usage

Go to any directory and init a new maestro project with the command maestro init

➜  maestro init
Config file & scripts directory created!

This command will create a new maestro/ folder, and put a few things in there for you.

➜  tree maestro
maestro
├── configuration.json
└── scripts
    ├── ls
    └── pwd

1 directory, 3 files

The maestro/configuration.json file is used to define targets. A target is a local or remote machine to run a command against.

{
  "targets": {
    "local": "127.0.0.1",
    "web": "user@192.168.1.1"
  }
}

You can list the available targets at any time by running maestro targets

➜  maestro targets
 ------- ------ -------------
  Name    User   IP Address
 ------- ------ -------------
  local          127.0.0.1
  web     user   192.168.1.1
 ------- ------ -------------

The maestro/scripts/ folder is where you will put any bash script that you would like to run against a target. By default we include two commands out of the box, ls and pwd. You can list all available scripts to run by running the command maestro scripts

➜  maestro scripts
 ------ ------------------------------------
  Name   Description
 ------ ------------------------------------
  ls     Runs ls -al command
  pwd    Gets the current working directory
 ------ ------------------------------------

The name of the script is just the script filename. The description of the script is a bash comment inside the bash script. You need to add # @description <your description> to make a description show up in the maestro scripts command.

➜  cat maestro/scripts/ls
#!/usr/bin/bash
# @description Runs ls -al command
set -e
ls -al

Let's make a new script that gets a machine's hostname. Note how we include set -e at the top of the script to terminate output if there is an error.

echo '#!/usr/bin/bash
# @description Gets the hostname of the machine
set -e
hostname' >maestro/scripts/hostname

Then, we can verify it comes up as valid script by re-running the maestro scripts command.

➜  maestro scripts
 ---------- ------------------------------------
  Name       Description
 ---------- ------------------------------------
  hostname   Gets the hostname of the machine
  ls         Runs ls -al command
  pwd        Gets the current working directory
 ---------- ------------------------------------

Finally, you can run script against a target by running maestro run <script name> <target name>

➜  maestro run hostname local
Running script hostname on 127.0.0.1
[127.0.0.1]: localhost

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email sam@onroi.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.