vagrant-flow 1.0.25 → 1.0.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -26
- data/lib/vagrant-flow/command/multicommand.rb +88 -0
- data/lib/vagrant-flow/command/root.rb +5 -1
- data/lib/vagrant-flow/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70ae05bd8a76968202c2f7b192ff4be321dba616
|
4
|
+
data.tar.gz: 5c0146d7b066532bc95502878518749214fb7070
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc6d35e04599c523066023780e4207f180f4b2bf8203cfd71af01224cbf8edb011a63b37ccf58cfc98914da025ff9c773887edaccd46d6679dc3319f6929e947
|
7
|
+
data.tar.gz: 3a913c6296071c810a9cffe33d07aa5e72a37605165f5bc4645db5168d089a2de6d1230f27a09c2531cb90d1459f645fe7f838f509de7ad78e32e32600f0d79c
|
data/README.md
CHANGED
@@ -38,6 +38,7 @@ multiinit
|
|
38
38
|
hostfile
|
39
39
|
ansibleinventory
|
40
40
|
playbook
|
41
|
+
multicommand
|
41
42
|
```
|
42
43
|
|
43
44
|
- multiinit
|
@@ -48,6 +49,8 @@ playbook
|
|
48
49
|
- Create a ansible machine inventory file so that you can use ansible to provision the machines
|
49
50
|
- playbook
|
50
51
|
- Uses a confile to run ansible-play book to provision one or more VM's
|
52
|
+
- multicommand
|
53
|
+
- Runs shell command on multiple machines
|
51
54
|
|
52
55
|
Example flow to be enabled
|
53
56
|
```
|
@@ -66,6 +69,8 @@ vagrant flow playbook
|
|
66
69
|
# or
|
67
70
|
ansible-playbook -i ansible-flow_inventoryfile ../DeveloperPlaybooks/site.yml
|
68
71
|
|
72
|
+
vagrant flow multicommand -c "/opt/startserver.sh"
|
73
|
+
|
69
74
|
#communication test
|
70
75
|
vagrant ssh boxname1 ping boxname2
|
71
76
|
vagrant ssh boxname2 ping boxname1
|
@@ -387,40 +392,29 @@ Example flow-playbook.yml file
|
|
387
392
|
```
|
388
393
|
|
389
394
|
* * *
|
395
|
+
##multicommand
|
396
|
+
```
|
397
|
+
Usage: vagrant flow multicommand [-qf] -c COMMAND
|
398
|
+
Runs a shell command on specified machines in your vagrantfile
|
390
399
|
|
391
|
-
|
392
|
-
|
400
|
+
-q, --quiet (Optional) Suppress output to STDOUT and STDERR
|
401
|
+
-f VMNAME,VNAME2..., (Optional) comma separated list of machines to run command on
|
402
|
+
--filterMachine
|
403
|
+
-c, --command COMMAND (REQUIRED) Command to run on the machines
|
404
|
+
-h, --help Print this help
|
405
|
+
```
|
393
406
|
|
407
|
+
This will run a command on all the machines in your Vagrantfile
|
394
408
|
```
|
395
|
-
|
396
|
-
ansible-inventory
|
397
|
-
hostfile-local
|
398
|
-
hostfile-remote
|
399
|
-
flow
|
409
|
+
vagrant flow multicommand -c "ls -la"
|
400
410
|
```
|
401
|
-
- init-flow -> creates a stub Vagrant file but takes more options
|
402
|
-
- ansible-inventory -> creates a ansible-inventory file from the virtualmachines that are there
|
403
|
-
- hostfile-local -> create a hostfile that can be appended to your /etc/hosts locally so you can reference the vm's
|
404
|
-
- hostfile-remote -> updates the /etc/hosts on all the vm's created by vagrant so they can talk to each other
|
405
|
-
- flow -> calls ansible-inventory and hostfile-remote in 1 command.
|
406
411
|
|
407
|
-
|
412
|
+
This will run a command ONLY on machines named flowTest1 and flowTest2
|
408
413
|
```
|
409
|
-
vagrant
|
410
|
-
git clone http://github.com/DemandCube/DeveloperPlaybooks
|
411
|
-
mkdir devsetup
|
412
|
-
cd devsetup
|
413
|
-
vagrant init-flow frontend1 frontend2:ubuntu-12
|
414
|
-
vagrant flow
|
415
|
-
ansible-playbook -i ansible-flow_inventoryfile ../DeveloperPlaybooks/site.yml
|
416
|
-
|
417
|
-
#communication test
|
418
|
-
vagrant ssh frontend1 ping frontend2
|
419
|
-
vagrant ssh frontend2 ping frontend1
|
414
|
+
vagrant flow multicommand -c "ls -la" -f flowTest1,flowTest2
|
420
415
|
```
|
421
416
|
|
422
|
-
|
423
|
-
|
417
|
+
* * *
|
424
418
|
|
425
419
|
## Development Flow
|
426
420
|
|
@@ -452,6 +446,7 @@ rake release
|
|
452
446
|
# install for real from the repo
|
453
447
|
|
454
448
|
vagrant plugin install vagrant-flow
|
449
|
+
|
455
450
|
```
|
456
451
|
|
457
452
|
# Background Research
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require "vagrant"
|
2
|
+
require 'optparse'
|
3
|
+
require 'tempfile'
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
#Require my library for talking to digitalocean
|
7
|
+
require File.expand_path(File.dirname(__FILE__) ) +"/digitalocean_api"
|
8
|
+
|
9
|
+
module VagrantPlugins
|
10
|
+
module CommandVagrantFlow
|
11
|
+
module Command
|
12
|
+
class MultiCommand < Vagrant.plugin("2", :command)
|
13
|
+
|
14
|
+
# Builtin from Command class
|
15
|
+
# Must override to provide a description
|
16
|
+
def self.synopsis
|
17
|
+
"Runs a command on all the machines in your vagrantfile"
|
18
|
+
end
|
19
|
+
|
20
|
+
def commandThread(machine,command, quiet)
|
21
|
+
begin
|
22
|
+
machine.communicate.execute(command)
|
23
|
+
if !quiet
|
24
|
+
puts "Command was ran successfully on: "+machine.config.vm.hostname
|
25
|
+
end
|
26
|
+
rescue
|
27
|
+
if !quiet
|
28
|
+
puts "Command FAILED on: "+machine.config.vm.hostname
|
29
|
+
@error_message="#{$!}"
|
30
|
+
puts @error_message
|
31
|
+
end
|
32
|
+
ensure
|
33
|
+
if !quiet
|
34
|
+
puts "----"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Builtin from Command class
|
40
|
+
# Must override to provide core functionality
|
41
|
+
def execute
|
42
|
+
options = {}
|
43
|
+
options[:destroy_on_error] = true
|
44
|
+
options[:parallel] = false
|
45
|
+
options[:provision_ignore_sentinel] = false
|
46
|
+
options[:quiet] = false
|
47
|
+
options[:filter] = []
|
48
|
+
|
49
|
+
opts = OptionParser.new do |o|
|
50
|
+
o.banner = "A NeverWinterDP technology from the Department of Badass.\n\n"+
|
51
|
+
"Usage: vagrant flow multicommand [-qf] -c COMMAND\n"+
|
52
|
+
"Runs a shell command on specified machines in your vagrantfile"
|
53
|
+
o.separator ""
|
54
|
+
|
55
|
+
o.on("-q", "--quiet", "(Optional) Suppress output to STDOUT and STDERR") do |f|
|
56
|
+
options[:quiet] = true
|
57
|
+
end
|
58
|
+
|
59
|
+
o.on("-f", "--filterMachine VMNAME,VNAME2...", Array, "(Optional) comma separated list of machines to run command on") do |f|
|
60
|
+
options[:filter] = f
|
61
|
+
end
|
62
|
+
|
63
|
+
o.on("-c", "--command COMMAND", "(REQUIRED) Command to run on the machines") do |f|
|
64
|
+
options[:command] = f
|
65
|
+
end
|
66
|
+
end
|
67
|
+
argv = parse_options(opts)
|
68
|
+
return if !argv
|
69
|
+
raise OptionParser::MissingArgument if options[:command].nil?
|
70
|
+
|
71
|
+
threads = []
|
72
|
+
|
73
|
+
with_target_vms(argv, :provider => options[:provider]) do |machine|
|
74
|
+
#return unless machine.communicate.ready?
|
75
|
+
if options[:filter].empty? or options[:filter].include? machine.config.vm.hostname
|
76
|
+
threads.push(Thread.new{commandThread(machine,options[:command],options[:quiet])})
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
threads.each {|t|
|
81
|
+
t.join
|
82
|
+
}
|
83
|
+
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
data/lib/vagrant-flow/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-flow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.26
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Morin
|
@@ -60,6 +60,7 @@ files:
|
|
60
60
|
- lib/vagrant-flow/command/ansibleinventory.rb
|
61
61
|
- lib/vagrant-flow/command/digitalocean_api.rb
|
62
62
|
- lib/vagrant-flow/command/hostfile.rb
|
63
|
+
- lib/vagrant-flow/command/multicommand.rb
|
63
64
|
- lib/vagrant-flow/command/multiinit.rb
|
64
65
|
- lib/vagrant-flow/command/playbook.rb
|
65
66
|
- lib/vagrant-flow/command/root.rb
|