Skip to content

[vagrant] Allow tasks on all/subset of vms - #177

Open
karlp wants to merge 1 commit into
fabtools:masterfrom
etactica:pulls/multi-vagrant
Open

karlp wants to merge 1 commit into
fabtools:masterfrom
etactica:pulls/multi-vagrant

Conversation

@karlp

@karlp karlp commented Sep 18, 2013

Copy link
Copy Markdown

This works by relying on the fact that vagrant's ssh-config for multiple
machines differs only in the host string.

Behaviour:

fab vagrant task # runs on all running vagrant vms
fab vagrant:name1 # runs on only name1 machine
fab vagrant:name3,name1" # run on name3 and name1

This fixes issue #176

This works by relying on the fact that vagrant's ssh-config for multiple
machines differs only in the host string.

Behaviour:

fab vagrant task          # runs on all running vagrant vms
fab vagrant:name1         # runs on only name1 machine
fab vagrant:name3,name1   # run on name3 and name1

Hosts are kept in the order they are entered, if given.
@karlp

karlp commented Sep 19, 2013

Copy link
Copy Markdown
Author

This is updated now. I suspect that with "vagrant.settings()" probably doesn't handle this either, but I honestly don't know how to use that, and I couldn't find any use of it in the tests.

@ronnix

ronnix commented Jan 2, 2014

Copy link
Copy Markdown
Collaborator

list_vms is broken here for me, using Vagrant 1.3.5.

Here is an example of vagrant status output:

$ vagrant status
Current machine states:

default                   running (vmware_fusion)

The VM is running. To stop this VM, you can run `vagrant halt` to
shut it down, or you can run `vagrant suspend` to simply suspend
the virtual machine. In either case, to restart it again, run
`vagrant up`.

So if we grep for "running", we get:

$ vagrant status | grep running
default                   running (vmware_fusion)
The VM is running. To stop this VM, you can run `vagrant halt` to

Vagrant 1.4 adds machine-readable output. Maybe we should require that.

@deanmalmgren

Copy link
Copy Markdown
Contributor

Now that I've stepped away from this for a while, I'm coming around to this idea. I rather like the ability to specify several specific vagrant machines from the command line.

Regarding @ronnix's point about --machine-readable output of vagrant 1.4, it sounds like an awesome idea. The only downside is that the documentation also makes it sound like this feature is likely to change quite a bit. What if we instead changed the grep command to something like this etactica#1

I still personally won't use the "all running by default", mostly because I tend to have one development environment with virtualbox and one production environment with rackspace running at all times. More often than not, I only want to run fab on one of those environments (either of which might consist of several vagrant VMs). So I'll still probably stick with the fab specify_hosts some_task pattern but that doesn't mean it won't be useful for others.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants