Code Monkey home page Code Monkey logo

Comments (4)

espenak avatar espenak commented on August 17, 2024

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.

rnhurt avatar rnhurt commented on August 17, 2024

Perfect! Thanks!

One suggestion I have would be to put this in the docs somewhere (howto, tutorial, etc.)

from awsfabrictasks.

espenak avatar espenak commented on August 17, 2024

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.

espenak avatar espenak commented on August 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.