Comments (4)
awsfabrictasks expects names to be unique. How do you tell your machines apart if they are all named Magento? If you want to make this work with awsfabrictasks, you will have to use another tag to describe your instances. You can use the ec2_*_tag
tasks to change the tags (or just use the webinterface).
Our API have good support for your use-case. Lets say you use the role=Magento
tag on all your Magento instances. You should then be able to use awsfabrictasks.ec2.api.Ec2InstanceWrapper
to create tasks that manage these instances. A simple example (may have some errors since this I write this from memory on my iphone):
from awsfabrictasks.ec2.api import Ec2InstanceWrapper, print_ec2_instance
from fabric.api import task, run, settings
@task
def print_uname():
run("uname -a")
@task
def list_magento_instances():
for instancewrapper in Ec2InstanceWrapper.get_by_tagvalue(tags={"role": "Magento"}): # in DEFAULT_REGION
# Some debugging print
print
print instancewrapper
print_ec2_instance(instancewrapper.instance)
# A more realistic usage example
ssh_uri = instancewrapper.get_ssh_uri()
key_filename = instancewrapper.get_ssh_key_filename()
with settings(key_filename=key_filename, host_string=ssh_uri):
# Run tasks here just as if you invoked ``awsfab -E myname <task>``
print_uname()
from awsfabrictasks.
Perfect! Thanks!
One suggestion I have would be to put this in the docs somewhere (howto, tutorial, etc.)
from awsfabrictasks.
Will add it later today or tomorrow. Think I will try to simplify it with a fabric.api.settings
-wrapper that makes it possible to do:
with instancewrapper.instance_settings(): # Supports any fabric.api.settings arguments, but key_filename and host_string is ignored/overridden
print_uname()
Instead of:
ssh_uri = instancewrapper.get_ssh_uri()
key_filename = instancewrapper.get_ssh_key_filename()
with settings(key_filename=key_filename, host_string=ssh_uri):
# Run tasks here just as if you invoked ``awsfab -E myname <task>``
print_uname()
from awsfabrictasks.
Also note that any improvements to the docs are welcome as pull requests, and feel free to add anything you think others may find useful to the wiki.
from awsfabrictasks.
Related Issues (14)
- Is there a way to specify an AWS IAM role when using awsfab ec2_launch_instance? HOT 6
- VPC instances HOT 4
- Could not find the env.awsfab_settings_module HOT 2
- @ec2instance decorator executed too early? HOT 6
- @ec2instance: login issue
- Doesn't work with Fabric 1.9.0+ HOT 1
- Getting the current Instance
- Requires ec2 with public DNS?
- lunching t2.micro instance is failing
- Rename ec2.api.ec2_rsync
- Implement instancewrapper.instance_settings()
- Recommended setup for multiple AWS accounts? HOT 1
- ec2_list_instances broken with boto 2.6.0 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from awsfabrictasks.