Control cloud servers using the provider's API
Project description
Shepherd
A.k.a. cloud-shepherd.
This is a tool for controlling a stable of hosts listed in an Ansible inventory file. (By the use of non-standard Ansible variables that identify the cloud provider, region and ID of the host.) It can also show their status.
Unlike Ansible, the purpose of Shepherd is to manage hosts without having to log into them. Actions are perfomed by contacting the API of one or more cloud providers.
Shepherd is intended to be used like virsh or service(1). Currently,
only AWS is supported. For certain tasks, it is friendlier than
vendor-provided tools like aws-cli (ec2
subcommand).
Specifying the inventory file
The filename can either be put into the ANSIBLE_INVENTORY
environment variable,
or supplied on the command line with --inventory-file=/x/y/z
(short option is
-i
).
Why not use Ansible's Dynamic Inventory feature?
The Dynamic Inventory plugin allow Ansible to pull down a list of hosts from a cloud provider and then manage them.
However, it can be handy to keep track hosts with names that are different from those in the AWS EC2 instance name tag, for example. Therefore the intent of Shepherd is to make the inventory file the locus of host management. It is deliberately not dynamic.
Installation
Run pip3 install cloud-shepherd
Setup
The following extra host variables must (unless specified) be present in the inventory file otherwise the host will not be operated on and a warning will be shown:
cloud_provider
-- choices:aws
cloud_account
-- optional (account ID for AWS)cloud_region
cloud_instance_id
A Makefile is provided (see shepherd/Makefile
) that uses an
internal AWK script to generate an Ansible inventory file from your .ssh/config
file. This brings all the regular Ansible variables across from corresponding
SSH settings in the file.
Note that the Makefile currently ignores all hosts in .ssh/config
that
aren't preceeded by a comment line that starts with an AWS EC2 instance ID.
YMMV.
Usage
Shepherd takes an action argument on the command line, plus a host pattern that will match one or more hosts in the inventory file. The program can be invoked in one of two ways.
virsh mode:
shepherd <action> <host-pattern>
shepherd list
...where <action>
is one of:-
- dominfo
- start
- reboot
- shutdown
- destroy
Or service(1) mode:
shepherd <host-pattern> <action>
...where <action>
is one of:-
- status
- fullstatus
- start
- restart
- stop
- kill
Also, the following AWS action names can be used instead:
- start
- reboot
- stop
- terminate
Options
Examples
Licence
GNU General Public License v3.0 or later
See COPYING to see the full text.
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
Built Distribution
File details
Details for the file cloud-shepherd-2.0.5.tar.gz
.
File metadata
- Download URL: cloud-shepherd-2.0.5.tar.gz
- Upload date:
- Size: 29.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31e1d3c649a569a333d40f347a6b2bab19f33cdd2fcbae571f7d7acb24370af5 |
|
MD5 | 26c35d242a15751fdff5a8aa25012fb6 |
|
BLAKE2b-256 | 2ed9f42710c74958648d051a7de8c356e74568689d70356470c9c6f91051c424 |
File details
Details for the file cloud_shepherd-2.0.5-py3-none-any.whl
.
File metadata
- Download URL: cloud_shepherd-2.0.5-py3-none-any.whl
- Upload date:
- Size: 35.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 760dba0373f065db5a86941107b61e895ac2230b1a35dba6c2372bd072ed1449 |
|
MD5 | 36fe2c5635109021f80ca0614cbca681 |
|
BLAKE2b-256 | 5bf00e8d16c5f0c5c3503c07cbed7d48c15b4d9bafba2a455b9c0d0626a40ffe |