Skip to main content

A cross-platform CLI client for Environment Manager

envmgr example

Install

pip install envmgr-cli

See Configuration for further install instructions.

Usage

envmgr is designed to provide an intuitive, human readable interface around the lower level Environment Manager Python Library

All envmgr commands are exposed behind a set of verbs (get a status, schedule some downtime, wait for an ASG, etc). Verbs are always the first value provided to envmgr and there is only ever one verb per command.

docopt

The cli interface is described in docopt. The easiest way to discover and understand the different usage patterns available is to simply run

envmgr --help

Output

By default, envmgr commands will output a human friendly response useful for testing single commands at a time. To help scripting or chaining results together, all commands also accept a --json argument which will return the raw JSON response from Environment Manager:

>> envmgr schedule asg my-asg on in prod
Scheduled 1 instance in my-asg to: ON

>> envmgr schedule asg my-asg on in prod --json
{"ChangedInstances": ["i-0afe2276909859130"], "ChangedAutoScalingGroups": ["my-asg"]}

Examples

In the examples below, assume that ‘prod-1’ is an environment, ‘AwesomeService’ is a service and ‘my-asg’ is an ASG, all of which are already registered in Environment Manager.

# Get the health status of all instances of AwesomeService, in all slices:
envmgr get AwesomeService health in prod-1

# Get the the active slice information for the AwesomeService service in prod-1 environment:
envmgr get AwesomeService active slice in prod-1

# Get the status of the my-asg ASG in the prod-1 environment. Status is calculated as an aggregate of all instances in the ASG:
envmgr get asg my-asg status in prod-1

# Get the schedule value set on the my-asg ASG in the prod-1 environment. Note this will tell you what the schedule is configured to - not the current state according to the schedule:
envmgr get asg my-asg schedule in prod-1

# Get the current status of the deployment with ID a2fbb0c0-ed4c-11e6-85b1-2b6d1cb68994:
envmgr get deploy status a2fbb0c0-ed4c-11e6-85b1-2b6d1cb68994

# Block and wait until the deployment with ID a2fbb0c0-ed4c-11e6-85b1-2b6d1cb68994 either succeeds or fails:
envmgr wait-for deploy a2fbb0c0-ed4c-11e6-85b1-2b6d1cb68994

# Block and wait until all instances in the ASG my-asg are ready fordeployment (In Service):
envmgr wait-for asg my-asg in prod-1

# Block and wait until the service AwesomeService is running with all healthchecks passing:
envmgr wait-for healthy AwesomeService in prod-1

# Set the schedule of the ASG my-asg in prod-1 to be off permanently until further notice:
envmgr schedule asg my-asg off in prod-1

# Publish the file build-22.zip as version 1.2.9 of AwesomeService:
envmgr publish build-22.zip as AwesomeService 1.2.9

# Deploy the published version 1.2.9 of AwesomeService into the prod-1 environment:
envmgr deploy AwesomeService 1.2.9 in prod-1

# Toggle the upstreams for AwesomeService in the prod-1 environment:
envmgr toggle AwesomeService in prod-1

# Get the Windows patch status for servers belonging to A-Team in prod-1:
envmgr get A-team patch status in prod-1

Configuration

Authentication

All calls to Environment Manager require authentication, which can be provided in 1 of 2 ways.

Either export your credentials as environment variables:

ENVMGR_USER=myusername
ENVMGR_PASS=mypa$$word

Or provide a --user and --pass value to each commad:

envmgr get MyService health in prod --user="sarah" --pass="pa$$word"

Note: It’s recommended to only use this method in CI environments.

Host Config

The hostname of your Environment Manager instance is configured similarly to your credentials:

Export your hostname as an environment variable:

ENVMGR_HOST=environmentmanager.acme.com

Or provide the hostname with each command:

envmgr get MyService health in prod --host=environmentmanager.acme.com

Development

To install all test dependencies and run all tests, simply run:

python setup.py test [--adopts -v]

For convenience this is also available via the included makefile:

make test

Docker

If you want, you can use our automated container builds

Usage

docker run -it --rm \
-e ENVMGR_USER=user
-e ENVMGR_PASS=password
-e ENVMGR_HOST=foo.bar
trainline/envmgr-cli:latest envmgr {YOUR_ARGS}

Example

~$ docker run -it --rm trainline/envmgr-cli envmgr --version
1.9.1

Build

docker build -t {YOUR_NAME}/envmgr-cli .

Release files for envmgr-cli 1.13.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for envmgr-cli 1.13.2
File Size Uploaded
envmgr-cli-1.13.2.tar.gz 20.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for envmgr-cli 1.13.2
File Interpreter ABI Platform
envmgr_cli-1.13.2-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 50.7 kB

Release files / envmgr-cli-1.13.2.tar.gz

Download URL envmgr-cli-1.13.2.tar.gz
Size 20.0 kB
Tags Source
SHA-256 checksum
How to use checksums
94f77ca46159e1c1a3ec26fa6f42e3f9c10cb016ebf7ba1945492d2b71f6c95b
BLAKE2b-256 checksum
How to use checksums
ca8ee024c35da1906bb4ffcf0809661417fe5fed18a2de3bd7aecd09d3ac2011
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.3

Release files / envmgr_cli-1.13.2-py2.py3-none-any.whl

Download URL envmgr_cli-1.13.2-py2.py3-none-any.whl
Size 30.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
0e63d1af162a216d8bd0fd8dc35bf7638957226ce36fcd006e64a634cd0e8b90
BLAKE2b-256 checksum
How to use checksums
75cfe9dd3136527364282a31981cb5ea0f8d7df6cb666e16941d664d96a6fbbd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.3

Release history Release notifications | RSS feed

This release

1.13.2 This release

2 release files

1.13.1

2 release files

1.12.1

2 release files

1.11.0

2 release files

1.10.0

2 release files

1.9.6

2 release files

1.9.5

2 release files

1.9.4

1 release file

1.9.3

1 release file

1.9.1

2 release files

1.9.0

2 release files

1.8.1

2 release files

1.8.0

2 release files

1.7.3

2 release files

1.7.2

2 release files

1.7.1

2 release files

1.7.0

2 release files

1.6.6

2 release files

1.6.5

2 release files

1.6.4

2 release files

1.6.3

2 release files

1.6.2

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.5

2 release files

1.5.4

2 release files

1.5.3

2 release files

1.5.2

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4.5

2 release files

1.4.4

2 release files

1.4.3

2 release files

1.4.2

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page