-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@ec2instance decorator executed too early? #15
Comments
As far as I can tell, you assume
One solution is to use Ec2 tags to save state, and use To sum this up, you will most likely want to do something like this: @tasks
def setup():
a = Ec2LaunchInstance(extra_tags={'Name': 'nginxserver', 'Environment': 'my_super_webapp'})
b = Ec2LaunchInstance(extra_tags={'Name': 'djangoserver', 'Environment': 'my_super_webapp'})
Ec2LaunchInstance.confirm_many([a, b])
Ec2LaunchInstance.run_many_instances([a, b])
# Note: that we can start doing stuff with ``a`` and ``b`` that does not
# require the instances to be running, such as setting tags.
Ec2LaunchInstance.wait_for_running_state_many([a, b])
@task
def dosomething():
"""
Typically called with ``awsfab --ec2tags my_super_webapp dosomething``.
"""
run('uname -a')
@task
@ec2instance(tags={'Environment': 'my_super_webapp'})
def dosomething_for_my_super_webapp():
"""
Called with ``awsfab dosomething_for_my_super_webapp``.
"""
run('whoami') You should also take a look at #11. |
Ah okay, thank you very much for the explanation! So this is not a bug, I just had a different mental model of what was going on ... Doing this via tags seems pretty neat. Just to make sure I got this right: Using the example fabfile you provided (thanks!), calling I copied the code from your comment into a
-- is that the expected behaviour? My understanding from your explanation was that at this point, the |
As far as I remember it should work like https://fabric.readthedocs.org/en/1.3.0/usage/parallel.html, but I have not used it for a couple of months and I created the code over a year ago so I may be remembering it wrong. If the tag matching does not work like specifying multiple hosts, we should provide another way of doing what you want to do using tags. |
Sorry -- could you explain what you mean by "it should work like |
Sorry that was not explained clearly! It should not work like |
Cheers! By sneaking in a couple of This means that in the particular case of the example code above, in decorator.py, line 34, |
Hi there, I'm trying to solve the following problem with awsfabrictasks: I would like to first start a certain number of instances, and then execute tasks on them.
I wrote a small task
setup
that creates a list ofEc2LaunchInstance
s, starts them usingEc2LaunchInstance.run_many_instances
, and callsEc2InstanceWrapper(instance.instance).add_instance_to_env()
on each of them.The idea was to then call
awsfabric setup task1 task2
, wheretask1
andtask2
would then be executed on the instances started fromsetup
. Unfortunatelyadd_instance_to_env()
does not seem to actually add the instance toenv
, and so this approach doesn't work.Now I was wondering
env
feels a little hacky.add_instance_to_env()
not result in that instance being added toenv
?The text was updated successfully, but these errors were encountered: