Skip to main content

Viper is a handy tool for easily running infrastructure management tasks and commands.

Project description

Viper Infrastructure Commander

PyPI version PyPI pyversions Build Status codecov Code style: black

Viper is a handy tool for easily running infrastructure management tasks and commands.

Viper CLI Examples.

Initialize current workspace (creates a viperdb.sqlite3 file)

viper init

# or remove or overwrite existing data with "-f" / "--force"

viper init -f

Load hosts from file

viper hosts:from-file tests/data/hosts.csv --indent 4

# or with a custom loader

viper hosts:from-file tests/data/hosts.json --loader viper.demo.loaders.json --indent 4

Load hosts from Python object

viper hosts:from-obj viper.demo.hosts.group1 --indent 4

Let's save the hosts

viper hosts:from-obj viper.demo.hosts.group1 > /tmp/hosts.json

Filter hosts

cat /tmp/hosts.json | viper hosts:filter viper.demo.filters.ip_starts_with_2 --indent 4

Assign tasks to the given hosts

cat /tmp/hosts.json | viper hosts:task viper.demo.tasks.ping --indent 4

Run the assigned tasks

cat /tmp/hosts.json | viper hosts:task viper.demo.tasks.ping | viper task-runners:run --indent 4

# or use a shortcut

cat /tmp/hosts.json | viper hosts:run-task viper.demo.tasks.ping --indent 4

Run tasks in parallel using multiple workers

cat /tmp/hosts.json | viper hosts:run-task viper.demo.tasks.ping --max-workers 50 --indent 4

Get the past task results of the hosts from DB

cat /tmp/hosts.json | viper hosts:task-results --indent 4 --debug

Or get the past task results by task

viper task:from-obj viper.demo.tasks.ping | viper task-results:by-task -i 4

# Or

viper task:from-obj viper.demo.tasks.ping | viper task:results -i 4

Let's save the result

viper task:from-obj viper.demo.tasks.ping | viper task:results > /tmp/results.json

Now filter the results by their status

# success
cat /tmp/results.json | viper task-results:filter viper.demo.filters.result_ok -i 4

# failed
cat /tmp/results.json | viper task-results:filter viper.demo.filters.result_errored -i 4

Pipe the results to a custom handler

cat /tmp/results.json | viper task-results:pipe viper.demo.handlers.print_status

Viper CLI Reference

usage: viper [-h] [--version] [--debug]
             {init,task:from-obj,task:results,hosts:from-file,hosts:from-obj,hosts:filter,hosts:count,hosts:sort,hosts:pipe,hosts:task,hosts:run-task,hosts:task-results,task-runners:filter,task-runners:count,task-runners:sort,task-runners:pipe,task-runners:run,task-runners:hosts,task-results:filter,task-results:count,task-results:sort,task-results:pipe,task-results:hosts,task-results:by-task}
             ...

Viper CLI v0.0.0

positional arguments:
  {init,task:from-obj,task:results,hosts:from-file,hosts:from-obj,hosts:filter,hosts:count,hosts:sort,hosts:pipe,hosts:task,hosts:run-task,hosts:task-results,task-runners:filter,task-runners:count,task-runners:sort,task-runners:pipe,task-runners:run,task-runners:hosts,task-results:filter,task-results:count,task-results:sort,task-results:pipe,task-results:hosts,task-results:by-task}
    init                initialize the current workspace
    task:from-obj       get the task from a python object location
    task:results        get the past task results of given task
    hosts:from-file     get a group of hosts from a file
    hosts:from-obj      get a group of hosts from a python object location
    hosts:filter        filter hosts by a given function
    hosts:count         count the number of hosts
    hosts:sort          sort the hosts
    hosts:pipe          pipe the hosts to the given function
    hosts:task          assign a task to each host
    hosts:run-task      assign a task to each host and run
    hosts:task-results  get the past task results of the hosts
    task-runners:filter
                        filter task runners by a given function
    task-runners:count  count the number of task runners
    task-runners:sort   sort the task runners
    task-runners:pipe   pipe the task runners to the given function
    task-runners:run    run the assigned tasks
    task-runners:hosts  get the hohsts from the task runners
    task-results:filter
                        filter task results by a given function
    task-results:count  count the number of task results
    task-results:sort   sort the task results
    task-results:pipe   pipe the task results to the given function
    task-results:hosts  get the hosts from the task results
    task-results:by-task
                        get the past task results of given task

optional arguments:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
  --debug               show traceback information when an exception is raised

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

viper-infra-commander-0.0.0.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

viper_infra_commander-0.0.0-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file viper-infra-commander-0.0.0.tar.gz.

File metadata

  • Download URL: viper-infra-commander-0.0.0.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.5

File hashes

Hashes for viper-infra-commander-0.0.0.tar.gz
Algorithm Hash digest
SHA256 db642f72d9d9a0934f3ffef0ee930f902798bca1278310e53576c22109aca99e
MD5 5fda45fbb228101f34e668199a124d77
BLAKE2b-256 145395cb8274cf8291f1b1b9308e0f5447591f577abf8474d99aec819ee950a3

See more details on using hashes here.

File details

Details for the file viper_infra_commander-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: viper_infra_commander-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.5

File hashes

Hashes for viper_infra_commander-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1878c132272b44ef46b406f22f00e2efea0f7b10648edb927f51c094774d604e
MD5 4c7446f11e550404cea12bb6a3319799
BLAKE2b-256 d2d5ea1f1868cc2565bf5633f03c1c16a38c5c856839b5cea9e962ba0de46377

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page