Git Product home page Git Product logo

sparrow's Introduction

NAME

Sparrow - multipurpose scenarios manager.

ATTENTION

This is Sparrow for Perl5 and it is no longer supported and deprecated.

If you're looking for Sparrow6 - Raku version of Sparrow, see Sparrow6

If you still want to use this version follow Sparrow for the latest CPAN release. However, pay attention that:

  • All Sparrow plugins are only compatible with Sparrow6 version.
  • SparrowHub repository is abolished and no longer exists

SYNOPSIS

Install

$ sudo yum install git # only required for installing private plugins
$ sudo yum install curl
$ cpanm Sparrow

Build statuses

Build Status Build status

Sparrow plugins

Sparrow plugins are shareable multipurpose scenarios distributed via central repository - SparrowHub. Every single plugin represents a various scripts to solve a specific task. Plugins are easily installed, configured and run on dedicated servers with the help of sparrow console client.

The notion of sparrow plugins is very close to the conception of CPAN modules in Perl or Ruby gems in Ruby. It's just a small suites of scripts to solve a specific tasks.

Supported plugin types.

Sparrow supports two types of plugins depending on underlying runner to execute plugin scenarios. They are:

To find a specific sparrow plugin say this:

$ sparrow plg search nginx

To install a sparrow plugin say this:

$ sparrow plg install nginx-check

See sparrow command line API below.

Sparrow client

Sparrow is a console client to search, install, setup and run various sparrow plugins.

Think about it as of cpan client for CPAN modules or gem client for Ruby gems.

You run Sparrow client by using sparrow command.

To print out Sparrow currently installed version, run this:

$ sparrow --version

Sparrow basic entities

Sparrow architecture comprises of 4 basic parts:

  • Plugins
  • Tasks
  • Projects
  • Task Boxes

Tasks

Task is configurable sparrow plugin. Some plugins does not require configuration and could be run as is, but many ones require some piece of input data. Thus sparrow task is a container for:

  • plugin
  • plugin configuration

Plugin configuration is just a text file in one of 4 formats:

  • Config::General format - consumed by Outthentic plugins
  • YAML format - consumed by both Swat and Outthentic plugins
  • JSON format - consumed by Outthentic plugins
  • Config::Tiny format - consumed by Swat plugins

Projects

Projects are logical groups of sparrow tasks. It is convenient to split a whole list of tasks to different logical groups. Like some tasks for system related issues - f.e. checking disk available space or inspecting stale processes, other tasks for web services related issues - f.e. checking nginx health or monitoring http errors in web server logs, so on.

Task Boxes

Sparrow tasks boxes are JSON format files to describe sequential tasks to run.

You could think about sparrow boxes as of multi tasks. Sparrow runs tasks from the box sequentially.

API

This is a sparrow command line API documentation.

Projects API

Sparrow project is a logical group of sparrow tasks. To create a project use sparrow project create command:

sparrow project create $project_name

Command examples:

# system level tasks
$ sparrow project create system

# web servers related tasks
$ sparrow project create web-servers

To get project information say this:

sparrow project show $project_name

For example:

$ sparrow project show system

To get projects list say this:

sparrow project list

To remove project data say this:

sparrow project remove $project_name

For example:

$ sparrow project remove web-servers

NOTE! This command will remove all project tasks as well!

Plugins API

To search available plugins use sparrow plg search command:

sparrow plg search $pattern

Where $pattern is Perl regular expression pattern.

Examples:

# find ssh-* plugins
$ sparrow plg search ssh

[found sparrow plugins]

type    name

public  ssh-sudo-check
public  ssh-sudo-try
public  sshd-check

# find package managers plugins
$ sparrow plg search package

[found sparrow plugins]

type    name

public  package-generic

To list all available plugins say this:

$ sparrow plg search 

Index API

Sparrow index is cached data used by sparrow to search plugins.

Index consists of two parts:

  • private plugins index , see SPL file section for details
  • public plugins index, PUBLIC PLUGINS section for details

There are two basic command to work with index:

  • sparrow index summary

This command will show timestamps and file locations for public and private index files.

  • sparrow index update

This command will fetch fresh index from SparrowHub and update local cached index.

This is very similar to what cpan index reload command does.

You need sparrow index update to get know about updates, changes of SparrowHub repository. For example when someone release new version of plugin.

See public plugins section for details on sparrow public plugins and SparrowHub.

Installing sparrow plugins

sparrow plg install $plugin_name

For example:

$ sparrow plg search  nginx        # to get know available nginx* plugins
$ sparrow plg install nginx-check  # to download and install a chosen plugin
$ sparrow plg install nginx-check --version 0.1.1 # install specific version

Installing plugin from local source:

$ cd /plg/src/ && sparrow plg install /path/to/source --local 

Install plugin from local source recursively:

$ sparrow plg install /path/to/plugins --local --recursive

This command will recursively go through /path/to/plugins directory and for every directory containing sparrow.json file runs sparrow plg install . command.

Forcefully reinstall plugin

Use force flag to reinstall local plugins:

$ sparrow plg install /path/to/source --local --recursive --force 

$ sparrow plg install /path/to/plugins --local --force 

Reinstall plugins dependencies

Use install-deps.. It only works with public plugins:

$ sparrow plg install cpan-upload --install-deps

To see installed plugin list say this:

$ sparrow plg list

To get installed plugin information say this:

sparrow plg show $plugin_name

To remove plugin installed use sparrow plg remove command:

sparrow plg remove $plugin_name

For example:

$ sparrow plg remove df-check

Getting plugin man page

If plugin author supply his plugin with man page it could be shown as:

sparrow plg man $plugin_name

For example:

$ sparrow plg man df-check

Aliase. info and help are just aliases for plg man command:

$ sparrow plg info df-check
$ sparrow plg help df-check

Tasks API

Create tasks

To create a task use sparrow task add command:

sparrow task add $project_name $task_name $plugin_name [opts]

Tasks always belong to projects, so to create a task you have to create a project first if not exists. Tasks binds a plugin with configuration, so to create a task you have to install a plugin first.

Command examples:

$ sparrow project create system
$ sparrow plg install df-check
$ sparrow task add system disk-health df-check

Options:

  • --quiet - suppress output of this command.

For example:

$ sparrow task add system disk-health df-check --quiet 1
  • --host - pass hostname parameter.

It's useful when create tasks for swat plugins

$ sparrow task add web nginx-check swat-nginx --host 127.0.0.1:80

Getting task list

To list all the task with projects use:

sparrow task list

You can filter tasks out by using --search options:

# list tasks with project name or task name matching `database` and `production` strings

$ sparrow task list --search database --search production

# you can use Perl5 regexps in --search filters:

$ sparrow task list --search database --search '(test|dev)'

Run plugins

There are two ways to run sparrow plugins:

  • as_is

  • as tasks

The first one is simplest as it does not require creating a task at all. If you don't want provide a specific plugin configuration, you may run a plugin as is using sparrow plg run command:

sparrow plg run [ parameters ]

For example:

$ sparrow plg run df-check

Parameters:

  • verbose

Sets verbose mode to get some extra message when running plugin

The second way requires task creation and benefits in applying specific configuration for a plugin:

sparrow task run $project_name $task_name [ parameters ]

For example:

$ sparrow task run system disk-health

See configuring tasks section on how one can configure task plugin.

Parameters:

  • verbose

Setting runtime parameters

NOTE! Runtime parameters are only supported for Outthentic plugins.

It is possible to pass whatever runtime configuration parameters when running tasks or plugins:

$ sparrow plg run df-check --param threshold=60

$ sparrow task run system disk-health --param threshold=60

# or even nested and multi parameters!

$ sparrow plg run foo --param foo.bar.baz=60 --param id=100

Runtime parameters override default parameters ones set in tasks configurations, see configuring tasks section.

Setting plugin runner parameters

When executing sparrow plugin sparrow relies on underlying runner defined by plugin type. There are two types of sparrow plugins:

  • Outthentic Plugins

  • SWAT Plugins

Both runners accept specific parameters.

For outthentic runner parameters follow Outthentic documentation.

For swat runner parameters follow Swat documentation.

Here are some examples:

# outthentic plugins:
$ sparrow task run system/disk-health --format concise --purge-cache 
$ sparrow task run system/disk-health --debug 2

# swat plugins:
$ sparrow task run web/nginx-check --prove -Q

Running tasks with cron

When running tasks with cron it is handy only have an output if something goes wrong, f.e. if plugin failed for some reasons. Use --cron flag to enable this behavior:

sparrow task run $project_name $task_name --cron

Running task with --cron flag suppress a normal output and only emit something in case of failures.

Example:

$ sparrow task system disk-health --cron # pleas keep quite if disk space is ok

Configuring tasks

Task configuration is a some input parameters consumed by plugin binded to task. User should consult plugin documentation to get know a certain structure of configuration data to feed.

Sparrow supports two configuration formats:

  • Config::Tiny ( Swat plugins )
  • Config::General ( Outthentic plugins )
  • YAML ( Outthentic and Swat plugins )
  • JSON ( Outthentic plugins )

Use task ini command to set task configuration:

sparrow task ini $project_name $task_name

For example:

$ export EDITOR=nano

# Config::General format

$ sparrow task ini system disk-health
# disk used threshold in %
threshold = 80

# JSON format
$ sparrow task ini system disk-health
{
  "threshold": 80
}

# YAML format
$ sparrow task ini system disk-health
# disk used threshold in %
threshold: 80

Having this sparrow will save plugin configuration in the file related to task and will use it during task run:

$ sparrow task run system disk-health # the value of threshold is 80

User could copy existed configuration from file using task load_ini command:

sparrow task load_ini $project_name $task_name /path/to/ini/file

For example:

$ sparrow task load_ini system disk-health /etc/plugins/disk.yaml # load from YAML file
$ sparrow task load_ini system disk-health /etc/plugins/disk.json # load from JSON file
$ sparrow task load_ini system disk-health /etc/plugins/disk.conf # load from Config::General file

To get task configuration use sparrow task show command:

sparrow task show $project_name $task_name

For example:

$ sparrow task show system disk-health

Alternative way to configure sparrow task is to load configuration from yaml/json file during task run:

$ cat disk.yml

---
threshold: 80

$ sparrow task run system disk --yaml disk.yml

$ cat disk.json

{
  "threshold": 80
}

$ sparrow task run system disk --json disk.json

While sparrow task ini/load_ini command saves task configuration and makes it persistent, sparrow task run --yaml|--json command applies plugin configuration only for runtime and won't save it after plugin execution.

For common usage, when user runs tasks manually first approach is more convenient, while the second one is a way automatic, when tasks configurations are kept as yaml files and maintained out of sparrow scope and applied during task run.

Removing tasks

Use this command to remove task from the project container:

sparrow task remove $project_name $task_name

Examples:

# remove task disk-health project system
$ sparrow task remove system disk-health

Alternative task names notation

When working with task you may use an alternative task names notation:

$project_name/$task_name

Examples:

$ sparrow task run system/disk
$ sparrow task show system/disk
$ sparrow task remove system/disk
$ sparrow task ini system/disk
# so on ...

Dump task configuration

You may dump task configuration using --dump-config flag, no action will be performed, just task configuration data will be printed out in JSON format:

$ sparrow task run system/disk --dump-config

Dump-config could be useful when copy some task configuration into other:

$ sparrow task run system/disk --dump-config > /tmp/system-disk.json
$ nano /tmp/system-disk.json
$ sparrow task load ini system/disk2 /tmp/system-disk.json

Copy task

If you need to copy existed task to another project use task copy command:

sparrow task copy project1 task project2 task2

This command copies task task1 from project project1 to project named project2 and give it a name task2

You can use alternative task notation here:

$ sparrow task copy project1/task1 project2/task2

Save/Restore tasks

To port tasks from one server to another use save|restore command:

$ sparrow task save /var/data/tasks

$ sparrow task restore /var/data/tasks

sparrow task save /path/to/tasks/dir

Sparrow task save command accept path to directory where existing tasks get dumped and saved to.

sparrow task restore /path/to/tasks/dir

Likewise sparrow task restore command accept path to directory with tasks to restore.

Merge option.

By default sparrow task save remove existing data ( if found ) from target directory. You disable this behavior by passing --merge option:

$ sparrow task save /var/data/tasks --merge # add currents tasks to existed in  /var/data/tasks

Ignore tasks.

You can omit some project/tasks from resulted save using task.ignore file:

$ nano ~/task.ignore

project1/task1
project2/task2

This will exclude the project1/task2 and project2/task2 tasks from resulted save. You can use regexp here:

$ nano ~/task.ignore

project1/.* # any tasks from project1
project2/task[2-9] # tasks 2 .. 9 from project2

The format of task ignore file:

project_name/task_name

Where project_name and task_name could be full names or regexps.

You may specify alternative location for task ignore file using --ignore option:

$ sparrow task save /var/data/tasks --ignore /etc/task.ignore

The default location for task ignore file is ~/task.ignore

Other options:

  • --quiet - makes output less verbose

Task boxes API

Run task box - collection of sparrow tasks.

sparrow box run $path [opts]

Where $path is the path to task box specification file ( json or yaml format).

The structure of task box specification file ( outthentic plugins ):

JSON:

[

  { // task1
    "task" : "task1_name",
    "plugin" : "plugin_name",
    "data" : { // plugin parameters
        "param1" : "value1",
        "param2" : "value2"
    }
  },
  { // task2
    "task" : "task2_name",
    "plugin" : "plugin_name",
    "data" : { // plugin parameters
        "param1" : "value1",
        "param2" : "value2"
    }
  }
  // so on
]

YAML:

---
# task1
- task: task1_name
  plugin: plugin name
  data:
    param1: value1
    param2: value2
# task2
- task: task2_name
  plugin: plugin_name
  data:
    param1: value1
    param2: value2
  # so on

Command example:

$ sparrow box run /var/sparrow/boxes/nginx.json

$ sparrow box run /var/sparrow/boxes/nginx.yaml

Task box specification file example:

JSON:

[

  {
    "task" : "install favorite packages",
    "plugin" : "package_generic",
    "data" : {
      "list" : "nano curl mc hunspell"
    }
  },
  {
    "task" : "setup git",
    "plugin" : "git-base",
    "data" : {
      "email" : "[email protected]", "name" : "Alexey Melezhik"
      
    }
  }

]

YAML:

---
- task: disk check
  plugin: df-check
  data:
    threshold: 95
- task: disk check
  plugin: df-check
  data:
    threshold: 95
- task: test plugin
  plugin: foo-generic
  data: {}
- task: test ruby plugin
  plugin: ruby-test
  data: {}

The structure of tasks box specification file ( swat plugins ):

JSON:

[
  // task1
  {
    "task" : "task1_name",
    "plugin" : "plugin_name",
    "type" : "swat",
    "host" : "http host"
  },
  // task2
  {
    "task" : "task2_name",
    "plugin" : "plugin_name",
    "type" : "swat",
    "host" : "http host"
  }
  // so on
]

YAML:

---
# task1
- task: task1_name
  plugin: plugin_name
  type: swat
  host: http host
# task2
- task: task2_name
  plugin: plugin_name
  type: swat
  host: http host
# so on

Sparrow box run parameters

To make command output less verbose ( suppress some details ) use --mode quiet option:

$ sparrow box run /path/to/my/box/ --mode quiet

Sparrow plugins

Sparrow plugins are shareable multipurpose scenarios installed from remote sources.

There are two type of sparrow plugins:

  • public plugins are provided by SparrowHub community repository and considered as public access.

  • private plugins are provided by internal or external git repositories and not necessary considered as public access.

Both public and private plugins are installed with help of sparrow client:

sparrow plg install plugin_name

Public plugins

The public plugins features:

  • they are kept in a central place called SparrowHub - community plugins repository.

  • they are versioned so you may install various version of a one plugin.

Private plugins

Private plugins are ones created by you and not supposed to be accessed publicly.

The private plugins features:

  • they are kept in arbitrary remote git repositories ( public or private ones )

  • they are not versioned, a simple `git clone/pull' command is executed to install/update a plugin

  • private plugins could be used by two methods:

  1. by SPL file
  2. by custom sparrow repository ( aka remote SPL file )

SPL file

SPL file is located at `~/sparrow.list' and contains lines in the following format:

$plugin_name $git_repo_url

Where:

  • git_repo_url

Is a remote git repository URL

  • plugin_name

A name of your sparrow plugin, could be arbitrary name but see restriction notice concerning public plugin names.

Example entries:

package-generic   https://github.com/melezhik/package-generic.git

Once you add a proper entries into SPL file you may list and install a private plugins:

$ sparrow index update
$ sparrow plg show package-generic

Custom sparrow repository

Custom sparrow repository is abstraction for remote SPL file.

To use existed custom repository add this to sparrow configuration file:

$ cat ~/sparrow.yaml

repo: 192.168.0.1:4441

This entry defines a custom repository accessible at remote host 192.168.0.1 port 4441

Once custom repository is set up you search and install custom repository plugins the same way as with private plugins defined at SPL file.

To run your own sparrow custom reposository use Sparrow::Nest module.

Developing sparrow plugins

As sparrow support two types of plugins - swat and outthentic, follow a related documentation pages on how to create scenarios suites to gets packaged and distributes as a sparrow plugin:

Publishing public sparrow plugin to SparrowHub

Once a plugin is create you should do 4 simple steps:

  • get registered on SparrowHub and create a token
  • setup sparrowhub.json file
  • create a plugin meta file - sparrow.json
  • upload a plugin with the help of sparrow plg upload command

Get registered on SparrowHub

Go to https://sparrowhub.org/sign_up and create an account

Generate a token

Login into SparrowHub, go to Profile page and hit "Regenerate Token" on https://sparrowhub.org/token page.

Setup sparrowhub.json

Once your get you token, setup a sparrowhub credentials on the machine where you are going upload plugin from:

$ cat ~/sparrowhub.json

{
    "user"  : "melezhik",
    "token" : "ADB4F4DC-9F3B-11E5-B394-D4E152C9AB83"
}

NOTE! Another way to provide SparrowHub credentials is to set $sph_user and $sph_token environment variables:

$ export sph_user=melezhik 
$ export sph_token=ADB4F4DC-9F3B-11E5-B394-D4E152C9AB83

Create a plugin meta file sparrow.json

Sparrow.json file holds plugin meta information required for plugin gets uploaded to SparrowHub.

Create sparrow.json file and place it in a plugin root directory:

{
    "name": "df-check",
    "version": "0.1.1",
    "plugin_type" : "outthentic"
    "description" : "elementary file system checks using df utility report ",
    "url" : "https://github.com/melezhik/df-check",
}

This is description of sparrow.json parameters:

  • name - plugin name.

Only symbols `a-zA-Z1-9_-.' are allowable in plugin name. This parameter is obligatory, no default value.

  • version - Perl version string.

This parameter is obligatory. A detailed information concerning version syntax could be find here - https://metacpan.org/pod/distribution/version/lib/version.pm

  • plugin_type - one of two - outthentic|swat - sets plugin internal runner.

This parameter is obligatory. Default value is outthentic.

  • url - a plugin web site http URL

This parameter is optional and could be useful when you want to refer users to plugin documentation site.

  • description - a short description of a plugin.

This one is optional, but very appreciated.

  • python_version - sets Python language version.

If you install pip modules targeted for Python3 you may set python_version in sparrow.json file:

python_version : 3

That makes sparrow plg install command use pip3 ( not pip ) to install dependencies by requirements.txt file

  • sparrow_version - sets minimal version of Sparrow required by plugin.

This is mostly useful for Sparrow developers. Some plugins may rely on the latest versions of Sparrow and couldn't run correctly on the older versions, to avoid any confusion plugins developers may declare a minimum version of Sparrow so that if the target machine does have it an exception will be raised instead of plugin execution when sparrow plg run command is invoked.

Upload plugin

  • Install sparrow client on your machine

    $ cpanm Sparrow

  • Go to directory where your plugin source code at and say:

    $ sparrow plg upload

That's it!

If you want to troubleshoot upload plugin errors use --verbose flag, when upload plugin.

Publishing private sparrow plugins

The process is almost the same as for public plugins, except you don't have to provide SparrowHub credentials and gets registered as you host your plugin at remote git repository.

You have to do 3 simple steps:

  • create a plugin and commit it into local git repository, plugin root directory should be repository root directory
  • create plugin meta file - sparrow.json and commit it into local git repository ( sparrow.json file is the same as for public plugins )
  • push your changes into remote git repository

Declaring dependencies

This is the way how one can declare dependencies for sparrow plugins:

+----------+-------------------+
| Language |  File             |
+----------+-------------------+
| Perl     | cpanfile          |
| Ruby     | Gemfile           |
| Python   | requirements.txt  |
+----------+-------------------+

You should place a dependency file into a plugin root directory.

Disable color output

To every action you may optionally add --nocolor flag to disable color output:

$ sparrow plg run df-check --nocolor

Sparrow client configuration file

This file should be placed at $SPARROW_ROOT/sparrow.yaml path ( see next section on SPARROW_ROOT ).

Configuration options:

  • repo

Custom sparrow repository

  • format

Defines format for outthentic reports, possible values are: default|concise|production

Environment variables

SPARROW_ROOT

Sets sparrow root directory.

If set than sparrow will be looking sparrow index, SPL and configuration files at following locations:

$SPARROW_ROOT/sparrow.index 
$SPARROW_ROOT/sparrow.list 
$SPARROW_ROOT/sparrow.yaml 

As well as projects, tasks and plugins data will be kept at $SPARROW_ROOT directory.

For example:

$ export SPARROW_ROOT=/opt/sparrow

SPARROW_NO_COLOR

Disable color output.

$ export SPARROW_NO_COLOR=1

Also see "Disable color output" section.

SPARROW_CONF_PATH

If set defines an alternative location for sparrow configuration file.

sparrow_hub_api_url

Sets alternative location of SparrowHub API. If not set Sparrow client uses https://sparrowhub.org as API URL.

Primarily used for internal testing and development. But also see offline mode support section.

SPARROW_UNSECURE

Disable ssl verification during sparrow plg upload, sparrow remote task run commands. Use this option on your risk.

Remote Tasks

WARNING! This feature is quite experimental and should be tested.

Remote tasks are sparrow tasks SparrowHub users could bind to theirs accounts:

$ sparrow project create utils

$ sparrow task add utils  git-setup git-base

$ sparrow task ini utils git-setup 

  email [email protected] 
  name  'Alexey Melezhik'

$ sparrow task run utils git-setup

Ok, now we could "wrap" our task and upload to our account:

$ sparrow remote task upload utils/git-setup

NOTE! to upload remote task you need a SparrowHub account.

Then I ssh-ing to another server to re-apply my git configuration:

$ ssh some-other-host
$ sparrow remote task install utils/git-setup

Now I can:

$ sparrow task run utils git-setup

Pretty cool, huh? :)))

A shortcut for sparrow remote task install ... & sparrow task run is:

$ sparrow remote task run utils/git-setup

Share your task

By default remote task uploaded to SparrowHub is only accessible by task author. This is so called private remote task. What if you want to share some fun stuff with people? - Share your task:

$ sparrow remote task share utils/nano-rc

Now users can use your remote task:

$ sparrow remote task install melezhik@utils/nano-rc
$ sparrow task run utils utils nano-rc

or using shortcut in single step:

$ sparrow remote task run melezhik@utils/nano-rc

NOTE! you don't need a SparrowHub account to use public remote tasks, even unregisters users can use public remote tasks.

Hide your task

Want to hide your task again? Not a problem:

$ sparrow remote task hide app/passwords

Now only you can use app/passwords task.

Add useful comments to task

When doing remote task upload you optionally can add a comment which will be show when task gets listed with sparrow remote task list command:

$ sparrow remote task upload utils/nano-rc 'makes nano.rc setup'

List remote tasks

To list your remote tasks ( both private and public ) say this:

$ sparrow remote task list

List public tasks

To get a list of available public remote tasks say this:

$ sparrow remote task public list

Remove remote task

And finally you can remove remote task:

$ sparrow remote task remove app/old-stuff

Offline mode support

For servers with limited or no access to internet, there is offline mode support.

Create local repository of Sparrow plugins

$ mkdir -p sparrow-local-repo/api/v1
$ mkidr -p sparrow-local-repo/plugins

Copy index file and plugins

$ curl https://sparrowhub.org/api/v1/index -o sparrow-local-repo/api/v1/index
$ curl https://sparrowhub.org/plugins/python-echo-script-v0.001000.tar.gz -o sparrow-local-repo/plugins/python-echo-script-v0.001000.tar.gz
$ # so on

Set sparrow_hub_api_url

$ export sparrow_hub_api_url=$PWD/sparrow-local-repo

Now Sparrow client will be looking for local repository instead of making requests to internet.

AUTHOR

Aleksei Melezhik

Home page

https://github.com/melezhik/sparrow

Copyright

Copyright 2015 Alexey Melezhik.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See also

  • SWAT - Simple Web Application Test framework.

  • Outthentic - Multipurpose scenarios framework.

Thanks

To God as the One Who inspires me to do my job!

sparrow's People

Contributors

manwar avatar melezhik avatar olshevskiy87 avatar thibaultduponchelle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sparrow's Issues

sshd-check plugin doesn't work now

hi! I am new in sparrow. Testing some plugins today I run sshd-check and it ended with error.

[spigell@hammerhead ~]$ sparrow plg run sshd-check
Can't open perl script "/home/spigell/.outthentic/tmp/13272/home/spigell/sparrow/plugins/public/sshd-check/sparrow.pl": No such file or directory
STATUS	FAILED (512)

Maybe the file one is looking for is under runnig dir:

[spigell@hammerhead ~]$ ls -laht /home/spigell/.outthentic/tmp/13169/home/spigell/sparrow/plugins/public/sshd-check/running/sparrow.pl

-rw-r--r-- 1 spigell users 995 Jan 20 19:24 /home/spigell/.outthentic/tmp/13169/home/spigell/sparrow/plugins/public/sshd-check/running/sparrow.pl

Sparrow task configuration

Здравствуйте. На текущий момент конфигурация тасков у sparrow при использовании json или yaml не самая удобная. То есть, команда sparrow task ini предполагает, что формат будет в Config::General, и если подложить yaml, то данные не подтянутся (Но в тоже время suite.yaml в корне плагина успешно работает). По крайней мере, у меня так. Есть ключ --yaml для тасков, но тогда не очень понятно зачем нужны задачи в таком случае. Ничего не имею против config::general, конечно.
Быть может, имеет смысл как-то заставить работать конфиги в формате json и yaml, когда они создаются комадой sparrow task ini, а ключи --yaml и --json перенести для команды sparrow plg run?

SparrowHub trouble

I'm trying sparrow for the first time here and may need some guidance, but there's a chance that something's off.

$ head sparrow.index
<!DOCTYPE html>
<html>
<head>

  <script src="/js/jquery-1.12.2.min.js"></script>

No plugin info shown in response to https://sparrowhub.org/info/perlbrew?v=0.001004, either.

add parameter supported_os in sparrow.json

Здравствуйте. Предлагаю добавить параметр в sparrow.json для указания поддерживаемых ОС.
Это позволит выдавать ошибку на неподдерживаемую ОС еще до запуска самого плагина. Я думаю, можно было бы сделать так:
Если есть этот параметр, то sparrow дергает функцию os и сравнивает вывод с значением (или массивом) параметра. Если все ок, то выполняем плагин, если нет - выдаем ошибку.
Если параметр не указан, то считаем, что плагин везде работает.
Как вы считаете, стоит ли это делать и возможно ли?

Problem with sparrow.list

Hi.

I'm trying to run '$ sparrow plg search ssh' (that's just an example. I get the same error all over) &
I get 'can't open /home/xxx/sparrow.list to read at /home/xxx/perl5/lib/perl5/Sparrow/Commands/Plugin.pm line 443'
also: 'Sparrow::Commands::Plugin::read_plugin_list() called at /home/xxx/perl5/lib/perl5/Sparrow/Commands/Plugin.pm line 43'
& lastly: 'Sparrow::Commands::Plugin::search_plugins() called at /home/xxx/perl5/bin/sparrow line 34'
Any help appreciated.
Cheers Phil.

setting parameter for sparrow check point during run time

Baed on #2 - it be good to set parameter for sparrow check point during run time, something like that:

rex Misc:Sparrow:Check --check system.disk --threshold=60

This task just will override default threshold value on per session basis and once check is done the default value for threshold still remain in ini file.

Sparrow doesn't get all string of parameters, but strun does

Здравствуйте. Столкнулся с такой штукой, что sparrow при передачи параметров берет только первый из строки, а не все. Strun работает корректно. Например,

[spigell@hammerhead ~]$ sparrow plg run bash-pssh --param commands=uname  --param hosts="194.87.235.183 193.124.178.59 " --debug 2 --param debug=1
make cache dir: /home/spigell/.outthentic/tmp/10319/story-0
configuration populated and saved to /home/spigell/.outthentic/tmp/10319/story-0/config.json
project: /home/spigell/sparrow/plugins/private/bash-pssh
story: /home/spigell/sparrow/plugins/private/bash-pssh
story_type: upstream
debug: 2
ignore story errors: 0
•[plg] bash-pssh at 2017-05-14 01:24:09

execute scenario: bash -c 'source /home/spigell/.outthentic/tmp/10319/story-0/glue.bash && source /usr/share/perl5/site_perl/auto/share/dist/Outthentic/outthentic.bash && source /home/spigell/sparrow/plugins/private/bash-pssh/story.bash'
+++ config hosts
+++ perl -MOutthentic::Glue::Bash -e json_var /home/spigell/.outthentic/tmp/10319/story-0/config.json hosts
++ hosts=194.87.235.183

В json конфиге только первое значение.
[spigell@hammerhead ~]$ cat /home/spigell/.outthentic/tmp/10319/story-0/config.json; echo
{"hosts":"194.87.235.183","debug":"1","commands":"uname"}

Если же все делать через strun, то получается все хорошо. Тот же самый плагин, те же самый параметры.

cd ./sparrow/plugins/private/bash-pssh/

[spigell@hammerhead bash-pssh]$ strun --param commands=uname  --param hosts="194.87.235.183 193.124.178.59 " --debug 2 --param debug=1
make cache dir: /home/spigell/.outthentic/tmp/10412/story-0
configuration populated and saved to /home/spigell/.outthentic/tmp/10412/story-0/config.json
project: /home/spigell/sparrow/plugins/private/bash-pssh
story: /home/spigell/sparrow/plugins/private/bash-pssh
story_type: upstream
debug: 2
ignore story errors: 0
• at 2017-05-14 01:27:58

execute scenario: bash -c 'source /home/spigell/.outthentic/tmp/10412/story-0/glue.bash && source /usr/share/perl5/site_perl/auto/share/dist/Outthentic/outthentic.bash && source /home/spigell/sparrow/plugins/private/bash-pssh/story.bash'
+++ config hosts
+++ perl -MOutthentic::Glue::Bash -e json_var /home/spigell/.outthentic/tmp/10412/story-0/config.json hosts
++ hosts='194.87.235.183 193.124.178.59 '

[spigell@hammerhead bash-pssh]$ cat /home/spigell/.outthentic/tmp/10412/story-0/config.json ;echo
{"commands":"uname","debug":"1","hosts":"194.87.235.183 193.124.178.59 "}

Посмотрите, пожалуйста.

dependencies for bash and python plugins.

Здравствуйте. Насколько я понимаю, для перла и руби есть в sparrow сделана поддержка для файлов cpanfile и gemfile. У питона так же есть https://en.wikipedia.org/wiki/Pip_(package_manager), с помощью которого можно было бы устанавливать зависимости. К сожалению, он далеко не во все пакеты python включен, к примеру на centos7 он не ставится вместе с питоном.

Также, можно было бы сделать что-то подобное для bash плагинов через плагин package-generic. Конечно, минус в том, что плагин мало ОС поддерживает.

Как вы считаете?

Pre-install tasks for plg install

Здравствуйте. В тикете #12 обсуждали, как сделать зависимости для баша. Сошлись на том, что лучше не добавлять это в sparrow, так как sparrow становится зависимым от package-generic очень сильно.

Если идти предложенным вами путем мне придется делать процесс установки sparrow плагинов зависимым от плагина sparrow package-generic, а sparrow изначально спроектирован так, что плагины не зависят друг от друга, это делает всю систему очень простой и надежной.
Из - #12 (comment)

Все-таки мы ситуацию с пакетами не решили, и недавно мне в голову пришла мысль: "А почему бы не давать возможность до установки плагина проводить какие-то действия?". Например, установка зависимостей для плагинов (системных пакетов) или очень минимальный провайзинг системы (создать лог файла).
Как я это вижу:

  1. В корне есть файлик pre-install.json. Это sparrow box.
  2. Если в плагине есть этот файлик, то вызываем функцию box_run из модуля Sparrow::Commands::TaskBox

Я понимаю, что решение не самое красивое, но по-другому придумать не смог.
Технически, можете посмотреть, это осуществимо?

Changing all sparrow plugins to be compatible with Outthentic >= 0.3.0

Приветствую!

В версии 0.3.0 модуля Outthentic

  1. check files стали необязательными, на данный момент есть много плагинов, где существуют пустые story.check файлы, теперь в них нет необходимости ...

  2. Так же наличие файла meta.txt перестало означать, что история не имеет сценария, то что до сих пора называлось мета историей ( технически это означало, что сценарий для такой истории никогда не вызывался, даже если и существовал ), теперь это просто файл, в котором вы можете положить произвольный текст, который будет выведен в отчете, при выполнение истории.

Я планирую в ближайшее время привести все мои плагины в соответствие с последний версий Outthentic, больше всего будет изменений , связанных с пунктом 1

Что бы плагины работали, необходимо обновить Outthentic на целевых серверах , насколько для вас ( @spigell ) это будет проблематично?

Add an interface to configure checkpoints

It would probably be nice to have a sparrow command that helps with configuring checkpoints, e.g. something like:

$ sparrow setconfig df-check --threshold=80

Of course, the above is just an example, not an exact syntax requested :)

The idea can also be extended to have a command to get the actual configuration values too.

sparrow-sshtule plugins hangs

Это скорее вопрос. Я подметил, что при работе, если в плагинах использовать команду ssh, то получаются странные ситуации. У меня есть скрипт, который с помощью sshuttle создает кучу vpn с серверами. У этой утилиты есть ключ -D, который говорит о том, что приложение уйдет в фон после запуска. При запуске в консольке и скриптах bash он отдает консольку. Но в плагинах sparrow он чего-то ожидает. Пример:

[spigell@puppet_sparrow-test sshuttle]$ strun --param host=193.124.178.59 --param subnet=192.168.23.0 --param netmask=24 --param check_ip=192.168.23.1 --debug 1
make cache dir: /home/spigell/.outthentic/tmp/25059/story-0
configuration populated and saved to /home/spigell/.outthentic/tmp/25059/story-0/config.json

[s] at 2017-02-23 11:25:04
+++ config host
+++ perl -MOutthentic::Glue::Bash -e json_var /home/spigell/.outthentic/tmp/25059/story-0/config.json host
++ host=193.124.178.59
+++ config subnet
+++ perl -MOutthentic::Glue::Bash -e json_var /home/spigell/.outthentic/tmp/25059/story-0/config.json subnet
++ subnet=192.168.23.0
+++ config netmask
+++ perl -MOutthentic::Glue::Bash -e json_var /home/spigell/.outthentic/tmp/25059/story-0/config.json netmask
++ netmask=24
+++ config user
+++ perl -MOutthentic::Glue::Bash -e json_var /home/spigell/.outthentic/tmp/25059/story-0/config.json user
++ user=spigell
+++ config check_ip
+++ perl -MOutthentic::Glue::Bash -e json_var /home/spigell/.outthentic/tmp/25059/story-0/config.json check_ip
++ check_host=192.168.23.1
++ sshuttle -v -D -r [email protected] 192.168.23.0/24
Starting sshuttle proxy.
Listening on ('127.0.0.1', 12298).
c : connecting to server...
c : connected.
Connected.




adsfasdf
ad
sa
asf^C
STATUS     FAILED (2)
[spigell@puppet_sparrow-test sshuttle]$ 

Можете подсказать, в чем дело может быть? Тоже самое, если зайти по ssh через sparrow скрипт:

[spigell@puppet_sparrow-test sshuttle]$ strun --param host=127.0.0.1

[s] at 2017-02-23 11:27:44
+++ config host
+++ perl -MOutthentic::Glue::Bash -e json_var /home/spigell/.outthentic/tmp/25270/story-0/config.json host
++ host=127.0.0.1
+++ config subnet
+++ perl -MOutthentic::Glue::Bash -e json_var /home/spigell/.outthentic/tmp/25270/story-0/config.json subnet
++ subnet=
+++ config netmask
+++ perl -MOutthentic::Glue::Bash -e json_var /home/spigell/.outthentic/tmp/25270/story-0/config.json netmask
++ netmask=
+++ config user
+++ perl -MOutthentic::Glue::Bash -e json_var /home/spigell/.outthentic/tmp/25270/story-0/config.json user
++ user=spigell
+++ config check_ip
+++ perl -MOutthentic::Glue::Bash -e json_var /home/spigell/.outthentic/tmp/25270/story-0/config.json check_ip
++ check_host=
++ ssh 127.0.0.1 bash
ls
perl5
sparrow
sparrow.index
sparrow.list
spigell
sshuttle
sshuttle.pid
sshuttle.sh
user
user-forked
^CSTATUS        FAILED (2)
[spigell@puppet_sparrow-test sshuttle]$ 

Incompatible with perl 5.26 ~

Hi,

Your
M/ME/MELEZHIK/Sparrow-0.3.2.tar.gz
M/ME/MELEZHIK/Outthentic-0.4.0.tar.gz
are now not compatible with perl 5.26 and above.

Please see http://blogs.perl.org/users/todd_rinaldo/2016/11/how-removing-from-inc-is-about-to-break-cpan.html

$ cpan Sparrow
Reading '/Users/user/.cpan/Metadata'
  Database was generated on Thu, 01 Nov 2018 00:29:03 GMT
Running install for module 'Sparrow'
CPAN: Digest::SHA loaded ok (v6.02)
CPAN: Compress::Zlib loaded ok (v2.081)
Checksum for /Users/user/.cpan/sources/authors/id/M/ME/MELEZHIK/Sparrow-0.3.2.tar.gz ok
CPAN: YAML loaded ok (v1.26)
CPAN: CPAN::Meta::Requirements loaded ok (v2.140)
CPAN: Parse::CPAN::Meta loaded ok (v2.150010)
CPAN: CPAN::Meta loaded ok (v2.150010)
CPAN: Module::CoreList loaded ok (v5.20181020)
Configuring M/ME/MELEZHIK/Sparrow-0.3.2.tar.gz with Makefile.PL
CPAN: CPAN::Reporter loaded ok (v1.2018)
Can't locate inc/Module/Install.pm in @INC (you may need to install the inc::Module::Install module) (@INC contains: ...... ) at Makefile.PL line 1.
BEGIN failed--compilation aborted at Makefile.PL line 1.
(/Users/user/perl5/perlbrew/perls/perl-5.26/bin/perl Makefile.PL exited with 512)

--silent or --quiet flag for all sparrow command

Здравствуйте. Иногда мне приходится парсить вывод из sparrow плагина. И также приходится отбрасывать последние строчки через sed. Неплохо было бы, если имелась возможность убирать строчки от sparrow о том. что все успешно/неуспешно.
То есть, запуская плагин с этим флагом, я хочу видеть только то, что выводит сам скрипт. Например,

[spigell@hammerhead ~]$ sparrow plg run bash --param command='"echo This is OUTPUT"'
{bash}
@ runs bash command

{bash} modules/bash-command/ params: envvars: at 2017-03-26 18:30:12
This is OUTPUT
ok	scenario succeeded
STATUS	SUCCEED

Тоже самое, но с этим флагом.

[spigell@hammerhead ~]$ sparrow plg run bash --param command='"echo This is OUTPUT"' --quiet

This is OUTPUT

Я честно не знаю как его назвать. Ведь у strun есть --silent, а у sparrow task есть --quiet
Да, я понимаю, что c этим флагом скорее всего не могут быть произведены проверки через файл story.check

Как вы считаете?

Issue with remote tasks

Здравствуйте. Если подставить другого юзера в sparrowhub.json

[spigell@hammerhead ~]$ cat ~/sparrowhub.json 
{
    "user"  : "melezhik",
	"token" : "..."
}

То можно увидеть список его задач

[spigell@hammerhead ~]$ sparrow remote task list | head -2
2017-04-07 17:16:34 private	foo_project/t1_task | t1 task
2017-04-07 17:16:32 private	baz_project/baz_task | %comment%

Эти задачи не мои. И поставить я их не могу, так sparrowhub отдает 401 http ошибку при установке из-за неправильного токена. Но тем не менее, странное поведение.

Также, в документации по Remote tasks опечатка:

A shortcut for sparrow remote task install ... & sparrow task run is:

$ sparrow remote task task run utils/git-setup

[spigell@hammerhead ~/my_configs/configs-tmux]$ sparrow remote task task run utils/git-setu
unknown command: task run utils/git-setu at /usr/bin/site_perl/sparrow line 230.

logging in sparrow client

Здравствуйте. У меня в планах есть создание плагина sparrow для запуска sparrowDO на мастер-хосте, т.е. что-то вроде git pull или puppet agent, так как не всегда целевые хосты включены во время "прогона" через sparrowDO. В связи с этим мне хотелось бы sparrow сам запускался (как это сделано уже не важно) и, что немаловажно, желательно, чтобы он что-то писал куда-нибудь. Мой вопрос именно в логировании. Возможно ли добавить в sparrow какое-то логирование в файл прямо в клиент (хотя бы с указанием времени запуска тестов и выводом результатов теста в читаемом виде из файла без указания цветовых последовательностей)? На текущий момент перенаправление из stdout в файл для сохранения результата работает, но потом смотреть это тяжело, на мой взгляд:
[spigell@hammerhead ~]$ sparrow plg run df-check > ./sparrow.log
Если сделать cat этого файла, то в stdout будет все нормально. Но в less или vim это будет смотрется так:

ESC[33m{df-check} ESC[0m
ESC[37mFilesystem                            Size  Used Avail Use% Mounted onESC[0m
ESC[37mdev                                   2.9G     0  2.9G   0% /devESC[0m
ESC[37mrun                                   2.9G  1.2M  2.9G   1% /runESC[0m
ESC[37m/dev/mapper/vg--arch--root-slashroot   25G   22G  2.3G  91% /ESC[0m
ESC[37mtmpfs                                 2.9G   27M  2.9G   1% /dev/shmESC[0m
ESC[37mtmpfs                                 2.9G     0  2.9G   0% /sys/fs/cgroupESC[0m
ESC[37mtmpfs                                 5.0G   64K  5.0G   1% /tmpESC[0m
ESC[37mtmpfs                                 5.0G     0  5.0G   0% /var/tmpESC[0m
ESC[37m/dev/sda1                             194M   90M   94M  49% /bootESC[0m
ESC[37m/dev/mapper/vg--arch--home-spigell     14G  9.5G  3.6G  73% /home/spigellESC[0m
ESC[37m/dev/mapper/vg--arch--home-music      6.8G  5.6G  821M  88% /home/spigell/musicESC[0m
ESC[37m/dev/mapper/vg--arch--home-downloads  9.8G  2.9G  6.4G  31% /home/spigell/downloadsESC[0m
ESC[37m/dev/mapper/vg--arch--home-VMs         26G   24G  512M  98% /home/spigell/VMsESC[0m
ESC[37mtmpfs                                 586M   12K  586M   1% /run/user/1000ESC[0m
ESC[37m/dev/sda3                              15G  5.9G  8.2G  42% /home/spigell/fedora-storESC[0m
ESC[37mOKESC[0m
ESC[32mok       scenario succeededESC[0m
threshhold: 80
ESC[32mok       text match /(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/ESC[0m
ESC[32mok       enough disk space (0%) on devESC[0m
ESC[32mok       enough disk space (1%) on runESC[0m
ESC[31mnot ok   enough disk space (91%) on /dev/mapper/vg--arch--root-slashrootESC[0m
ESC[32mok       enough disk space (1%) on tmpfsESC[0m
ESC[32mok       enough disk space (0%) on tmpfsESC[0m
ESC[32mok       enough disk space (1%) on tmpfsESC[0m
ESC[32mok       enough disk space (0%) on tmpfsESC[0m
ESC[32mok       enough disk space (49%) on /dev/sda1ESC[0m
ESC[32mok       enough disk space (73%) on /dev/mapper/vg--arch--home-spigellESC[0m
ESC[31mnot ok   enough disk space (88%) on /dev/mapper/vg--arch--home-musicESC[0m
ESC[32mok       enough disk space (31%) on /dev/mapper/vg--arch--home-downloadsESC[0m
ESC[31mnot ok   enough disk space (98%) on /dev/mapper/vg--arch--home-VMsESC[0m
ESC[32mok       enough disk space (1%) on tmpfsESC[0m
ESC[32mok       enough disk space (42%) on /dev/sda3ESC[0m
ESC[31mSTATUS   FAILED (256)
ESC[0m

Конечно, можно убрать эти символы из файла через регулярки, оставить только неудачные тесты, но это неудобно.
Как вы считаете, нужно ли логирование? Возможно. что-то удобное есть в sparrowUP, но я честно не вижу смысла мне его ставить.

plg man for private plugins

Здравствуйте. Я через sparrow.list добавил и установил приватный плагин.

[spigell@puppet_sparrow-test sshuttle]$ sparrow plg list user-spigell-dev
[installed sparrow plugins]

[public]

user


[private]

user-spigell-dev

Но дока все равно берется не из того каталога.

[spigell@puppet_sparrow-test sshuttle]$ sparrow plg man user-spigell-dev
cat: /home/spigell/sparrow/plugins/public/user-spigell-dev/README.md: No such file or directory

Взгляните, как будет время.
Спасибо.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.