vagrant-flow 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +128 -45
- data/lib/vagrant-flow/command/hostfile.rb +121 -0
- data/lib/vagrant-flow/command/root.rb +5 -0
- 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: ed22614eed524505d9e9152a08ed39f8d6a58742
|
|
4
|
+
data.tar.gz: 2108ba81c16ea08078a6ee9d0aaabe76d00defc5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7ad70c3ef275f2e791416ee322cf8cea97019b3d3380ae7b503d8287a95ea5b69d039c0ef58f4e7a3991c9d451db6f6313dfc8b298aa122d52709090f77dd187
|
|
7
|
+
data.tar.gz: 5501496525b98e3f696e3f43caf7490466e2d611aa2cc364b1c4f2ba95471c116effdebad7095c912bb6ce0724fa3387e22ea8eb4f551c0e430f09c87a8d9769
|
data/README.md
CHANGED
|
@@ -25,6 +25,100 @@ Or install it yourself as:
|
|
|
25
25
|
* * *
|
|
26
26
|
|
|
27
27
|
# Usage
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
* * *
|
|
31
|
+
## multiinit
|
|
32
|
+
```
|
|
33
|
+
Usage: vagrant flow multiinit [-hgliq]
|
|
34
|
+
This looks for multiinit.yml as the default configuration
|
|
35
|
+
|
|
36
|
+
-g FILEPATH, (Optional) YAML file containing vagrant cloud config
|
|
37
|
+
--vagrant_multiinit_config_file
|
|
38
|
+
-l hostname:cloud/location,hostname2:cloud/location2,hostname3:cloud/location3,
|
|
39
|
+
--list List of cloud config parameters
|
|
40
|
+
-i, --vboxintnet NAME (Optional) Custom virtualbox__intnet name for private network
|
|
41
|
+
-q, --quiet (Optional) Suppress output to STDOUT and STDERR
|
|
42
|
+
-h, --help Print this help
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
#### Example usages of multiinit
|
|
46
|
+
This will look for a file in the pwd named multiinit.yml and attempt to make the Vagrantfile
|
|
47
|
+
```
|
|
48
|
+
vagrant flow multiinit
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
This will look for a file in the pwd named myOwnGroupConfig.yml and attempt to make the inventory
|
|
54
|
+
```
|
|
55
|
+
vagrant flow multiinit -g myOwnMultiInitConfig.yml
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
This will read in from the command line a list of [vm_name]:[url] combinations. It MUST follow the following format. The -i option will also set the virtualbox__intnet name to a custom option ("virtualboxprivatenet" in this case)
|
|
61
|
+
```
|
|
62
|
+
vagrant flow multiinit -l boxname1:demandcube/centos-65_x86_64-VB-4.3.8,boxname2:demandcube/centos-65_x86_65-VB-4.3.8,box3:provider/boxname -i virtualboxprivatenet
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
### Use case
|
|
67
|
+
```
|
|
68
|
+
#Create your multi-box Vagrantfile
|
|
69
|
+
vagrant flow multiinit
|
|
70
|
+
#Launch the boxes
|
|
71
|
+
vagrant up
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Example multiinitconfig.yml file (for use with no optional command line arguments or by pointing to non-default file with -g option). The format of this yaml file MUST be followed, but can easily be expanded to include more of fewer machines
|
|
75
|
+
```
|
|
76
|
+
---
|
|
77
|
+
:intnetName: neverwinterDP
|
|
78
|
+
machines:
|
|
79
|
+
- name: machine1
|
|
80
|
+
url: demandcube/centos-65_x86_64-VB-4.3.8
|
|
81
|
+
- name: server1
|
|
82
|
+
url: demandcube/centos-64_x86_64-VB-4.3.8
|
|
83
|
+
- name: jenkinstestmachine
|
|
84
|
+
url: demandcube/centos-65_x86_64-VB-4.3.8
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
* * *
|
|
89
|
+
##hostfile
|
|
90
|
+
Usage: vagrant flow hostfile [-hnkq]
|
|
91
|
+
Edits all your VMs /etc/hosts file to be able to find all the machines on your private network
|
|
92
|
+
|
|
93
|
+
-q, --quiet (Optional) Suppress output to STDOUT and STDERR
|
|
94
|
+
-n, --no-write-hosts (Optional) Don't actually write a new hosts file to the guest machine
|
|
95
|
+
-h, --help Print this help
|
|
96
|
+
|
|
97
|
+
#### Example usages of hostfile
|
|
98
|
+
This will look through your vagrantfile config, find all the hostnames and IP's configured in your private_network, and append that information to all your machine's /etc/hosts file
|
|
99
|
+
```
|
|
100
|
+
vagrant flow hostfile
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Example Vagrantfile excerpt. This configuration is required by hostfile to be able to determine IP addresses and hostnames.
|
|
104
|
+
If you're already using vagrant flow multiinit, then this configuration is already take care of
|
|
105
|
+
```
|
|
106
|
+
config.vm.define :server1 do | server1 |
|
|
107
|
+
server1.vm.box = "demandcube/centos-65_x86_64-VB-4.3.8"
|
|
108
|
+
# Create a private network
|
|
109
|
+
server1.vm.network :private_network, ip: "192.168.1.2", virtualbox__intnet: "neverwinterDP"
|
|
110
|
+
server1.vm.hostname = "server1"
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
config.vm.define :server2 do | server2 |
|
|
114
|
+
server2.vm.box = "demandcube/centos-65_x86_64-VB-4.3.8"
|
|
115
|
+
# Create a private network
|
|
116
|
+
server2.vm.network :private_network, ip: "192.168.1.3", virtualbox__intnet: "neverwinterDP"
|
|
117
|
+
server2.vm.hostname = "server2"
|
|
118
|
+
end
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
* * *
|
|
28
122
|
## ansibleinventory
|
|
29
123
|
```
|
|
30
124
|
Usage: vagrant flow ansibleinventory [-hgpq]
|
|
@@ -66,7 +160,7 @@ vagrant flow ansibleinventory -p
|
|
|
66
160
|
#Bring up your vagrant machines
|
|
67
161
|
vagrant up
|
|
68
162
|
#Run ansible inventory (this assumes the file groupconfig.yml exists)
|
|
69
|
-
vagrant
|
|
163
|
+
vagrant flow ansibleinventory
|
|
70
164
|
#point ansible-playbook to the generated vagrant-flow_ansible_inventory, and point them to whatever playbook you'd like
|
|
71
165
|
ansible-playbook -i path/to/vagrant-flow_ansible_inventory my_playbook.yml
|
|
72
166
|
```
|
|
@@ -118,67 +212,56 @@ Example playbook.yml to use after ansible-inventory has run with command `ansibl
|
|
|
118
212
|
roles:
|
|
119
213
|
- apache
|
|
120
214
|
```
|
|
121
|
-
* * *
|
|
122
|
-
## multiinit
|
|
123
|
-
```
|
|
124
|
-
Usage: vagrant flow multiinit [-hgliq]
|
|
125
|
-
This looks for multiinit.yml as the default configuration
|
|
126
215
|
|
|
127
|
-
|
|
128
|
-
--vagrant_multiinit_config_file
|
|
129
|
-
-l hostname:cloud/location,hostname2:cloud/location2,hostname3:cloud/location3,
|
|
130
|
-
--list List of cloud config parameters
|
|
131
|
-
-i, --vboxintnet NAME (Optional) Custom virtualbox__intnet name for private network
|
|
132
|
-
-q, --quiet (Optional) Suppress output to STDOUT and STDERR
|
|
133
|
-
-h, --help Print this help
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
#### Example usages of multiinit
|
|
137
|
-
This will look for a file in the pwd named multiinit.yml and attempt to make the Vagrantfile
|
|
138
|
-
```
|
|
139
|
-
vagrant flow multiinit
|
|
216
|
+
Example output (file will be called vagrant-flow_ansible_inventory)
|
|
140
217
|
```
|
|
218
|
+
# Generated by vagrant-flow, part of NeverwinterDP
|
|
141
219
|
|
|
220
|
+
[testgroup]
|
|
221
|
+
jenkins ansible_ssh_host=127.0.0.1 ansible_ssh_port=2201 ansible_ssh_user=vagrant ansible_ssh_private_key_file=/Users/rcduar/.vagrant.d/insecure_private_key # Machine Name: jenkins
|
|
142
222
|
|
|
223
|
+
[servergroup]
|
|
224
|
+
server1 ansible_ssh_host=127.0.0.1 ansible_ssh_port=2222 ansible_ssh_user=vagrant ansible_ssh_private_key_file=/Users/user/.vagrant.d/insecure_private_key # Machine Name: server1
|
|
143
225
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
226
|
+
[common:children]
|
|
227
|
+
testgroup
|
|
228
|
+
servergroup
|
|
147
229
|
```
|
|
148
230
|
|
|
231
|
+
* * *
|
|
149
232
|
|
|
150
233
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
vagrant flow multiinit -l boxname1:demandcube/centos-65_x86_64-VB-4.3.8,boxname2:demandcube/centos-65_x86_65-VB-4.3.8,box3:provider/boxname -i virtualboxprivatenet
|
|
154
|
-
```
|
|
234
|
+
## Future Usage and Specs
|
|
235
|
+
Looking for vagrant-flow to have the following commands:
|
|
155
236
|
|
|
156
|
-
|
|
157
|
-
### Use case
|
|
158
237
|
```
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
238
|
+
init-flow
|
|
239
|
+
ansible-inventory
|
|
240
|
+
hostfile-local
|
|
241
|
+
hostfile-remote
|
|
242
|
+
flow
|
|
163
243
|
```
|
|
244
|
+
- init-flow -> creates a stub Vagrant file but takes more options
|
|
245
|
+
- ansible-inventory -> creates a ansible-inventory file from the virtualmachines that are there
|
|
246
|
+
- hostfile-local -> create a hostfile that can be appended to your /etc/hosts locally so you can reference the vm's
|
|
247
|
+
- hostfile-remote -> updates the /etc/hosts on all the vm's created by vagrant so they can talk to each other
|
|
248
|
+
- flow -> calls ansible-inventory and hostfile-remote in 1 command.
|
|
164
249
|
|
|
165
|
-
Example
|
|
250
|
+
Example flow to be enabled
|
|
166
251
|
```
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
- name: jenkinstestmachine
|
|
175
|
-
url: demandcube/centos-65_x86_64-VB-4.3.8
|
|
252
|
+
vagrant plugin install vagrant-flow
|
|
253
|
+
git clone http://github.com/DemandCube/DeveloperPlaybooks
|
|
254
|
+
mkdir devsetup
|
|
255
|
+
cd devsetup
|
|
256
|
+
vagrant init-flow frontend1 frontend2:ubuntu-12
|
|
257
|
+
vagrant flow
|
|
258
|
+
ansible-playbook -i ansible-flow_inventoryfile ../DeveloperPlaybooks/site.yml
|
|
176
259
|
|
|
260
|
+
#communication test
|
|
261
|
+
vagrant ssh frontend1 ping frontend2
|
|
262
|
+
vagrant ssh frontend2 ping frontend1
|
|
177
263
|
```
|
|
178
264
|
|
|
179
|
-
|
|
180
|
-
* * *
|
|
181
|
-
|
|
182
265
|
## Contributing
|
|
183
266
|
|
|
184
267
|
1. Fork it ( http://github.com/DemandCube/vagrant-flow/fork )
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
require "vagrant"
|
|
2
|
+
require 'optparse'
|
|
3
|
+
require 'tempfile'
|
|
4
|
+
|
|
5
|
+
module VagrantPlugins
|
|
6
|
+
module CommandVagrantFlow
|
|
7
|
+
module Command
|
|
8
|
+
class HostFile < Vagrant.plugin("2", :command)
|
|
9
|
+
|
|
10
|
+
# Builtin from Command class
|
|
11
|
+
# Must override to provide a description
|
|
12
|
+
def self.synopsis
|
|
13
|
+
"Sets /etc/hosts so that all your machines can communicate with each other"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# Builtin from Command class
|
|
18
|
+
# Must override to provide core functionality
|
|
19
|
+
def execute
|
|
20
|
+
options = {}
|
|
21
|
+
options[:destroy_on_error] = true
|
|
22
|
+
options[:parallel] = false
|
|
23
|
+
options[:provision_ignore_sentinel] = false
|
|
24
|
+
options[:nowrite] = false
|
|
25
|
+
options[:quiet] = false
|
|
26
|
+
|
|
27
|
+
#Parse option, look up OptionParser documentation
|
|
28
|
+
opts = OptionParser.new do |o|
|
|
29
|
+
# o.banner = "Usage: vagrant ansible-inventory [vm-name] [options] [-h]"
|
|
30
|
+
o.banner = "A NeverWinterDP technology from the Department of Badass.\n\n"+
|
|
31
|
+
"Usage: vagrant flow hostfile [-hnkq]\n"+
|
|
32
|
+
"Edits all your VMs /etc/hosts file to be able to find all the machines on your private network"
|
|
33
|
+
o.separator ""
|
|
34
|
+
|
|
35
|
+
o.on("-q", "--quiet", "(Optional) Suppress output to STDOUT and STDERR") do |f|
|
|
36
|
+
options[:quiet] = true
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
o.on("-n", "--no-write-hosts", "(Optional) Don't actually write a new hosts file to the guest machine") do |f|
|
|
40
|
+
options[:nowrite] = true
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
argv = parse_options(opts)
|
|
44
|
+
return if !argv
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
hostinfo=[]
|
|
48
|
+
#Go through config
|
|
49
|
+
#Map hostnames to IP's
|
|
50
|
+
with_target_vms(argv, :provider => options[:provider]) do |machine|
|
|
51
|
+
return unless machine.communicate.ready?
|
|
52
|
+
hostname = machine.config.vm.hostname
|
|
53
|
+
machine.config.vm.networks.each {|networks|
|
|
54
|
+
networks.each {|net|
|
|
55
|
+
if net.is_a?(Hash) and net.has_key?(:ip)
|
|
56
|
+
hostinfo.push(
|
|
57
|
+
{
|
|
58
|
+
:hostname=>hostname,
|
|
59
|
+
:ip=>net[:ip]
|
|
60
|
+
})
|
|
61
|
+
end
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
#What we're going to add to the end of the guest's hostfile
|
|
67
|
+
#A combination of IP's and hostnames
|
|
68
|
+
toconcatenate="\n"+"##ADDED BY NEVERWINTERDP'S VAGRANT-FLOW HOSTFILE COMMAND"+"\n"
|
|
69
|
+
hostinfo.each {|x|
|
|
70
|
+
toconcatenate+=x[:ip]+" "+x[:hostname]+"\n"
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
#Read in guest's current hosts file
|
|
75
|
+
#Append our new entries to it
|
|
76
|
+
#Write it out onto the guest's hosts file
|
|
77
|
+
with_target_vms(argv, :provider => options[:provider]) do |machine|
|
|
78
|
+
return unless machine.communicate.ready?
|
|
79
|
+
|
|
80
|
+
#This block of code was shamelessly stolen from
|
|
81
|
+
#https://github.com/smdahlen/vagrant-hostmanager/blob/master/lib/vagrant-hostmanager/hosts_file.rb
|
|
82
|
+
#Why reinvent the wheel?
|
|
83
|
+
#Determines what the move command and where /etc/hosts should be for linux, windows, and sunOS
|
|
84
|
+
if (machine.communicate.test("uname -s | grep SunOS"))
|
|
85
|
+
realhostfile = '/etc/inet/hosts'
|
|
86
|
+
move_cmd = 'mv'
|
|
87
|
+
elsif (machine.communicate.test("test -d $Env:SystemRoot"))
|
|
88
|
+
realhostfile = "#{ENV['WINDIR']}\\System32\\drivers\\etc\\hosts"
|
|
89
|
+
move_cmd = 'mv -force'
|
|
90
|
+
else
|
|
91
|
+
realhostfile = '/etc/hosts'
|
|
92
|
+
move_cmd = 'mv'
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
#Back to my code
|
|
96
|
+
#Grab Vagrant's temp file location
|
|
97
|
+
guesthostfilepath = @env.tmp_path.join("hosts."+machine.config.vm.hostname)
|
|
98
|
+
#Download guest's hosts file
|
|
99
|
+
machine.communicate.download(realhostfile, guesthostfilepath)
|
|
100
|
+
|
|
101
|
+
#Append our hostname/IP info to the end of the hosts file
|
|
102
|
+
guesthostfile = File.open(guesthostfilepath,"a")
|
|
103
|
+
guesthostfile.write(toconcatenate)
|
|
104
|
+
guesthostfile.close()
|
|
105
|
+
|
|
106
|
+
if not options[:nowrite]
|
|
107
|
+
#Upload updated hosts file to guest to temp location
|
|
108
|
+
machine.communicate.upload(guesthostfile.path, '/tmp/hosts')
|
|
109
|
+
#Move temp file over on top of hosts file
|
|
110
|
+
machine.communicate.sudo(move_cmd+" /tmp/hosts "+realhostfile)
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
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.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Steve Morin
|
|
@@ -54,6 +54,7 @@ files:
|
|
|
54
54
|
- create_sample_multiinit_input-file.rb
|
|
55
55
|
- lib/vagrant-flow.rb
|
|
56
56
|
- lib/vagrant-flow/command/ansibleinventory.rb
|
|
57
|
+
- lib/vagrant-flow/command/hostfile.rb
|
|
57
58
|
- lib/vagrant-flow/command/multiinit.rb
|
|
58
59
|
- lib/vagrant-flow/command/root.rb
|
|
59
60
|
- lib/vagrant-flow/plugin.rb
|