Toquen Python Library
This library is a small wrapper around some boto3 functions that allows users of the Toquen project to fetch server information in Python projects.
Installation
pip install toquen
Usage
This assumes you have a working familiarity with Toquen.
Assuming you want to be able to set up roles in your Fabric with the host locations of your servers in AWS, use this form:
from fabric.api import env, roles, run
from toquen import client
aws = client.FabricFriendlyClient()
env.roledefs = {
'staging': aws.ips_with_roles(['web'])
}
def dosomething():
run('ls /home')
Then, on the command line, you can run the dosomething
task over all servers with the staging
role like this:
fab -R staging dosomething
Easy peasy.