vagrant-flow 1.0.2 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 92db8f3c803af815f86d35449631d5e9970063bd
4
- data.tar.gz: 0cc86fd855e718068bdb3ea9f331a0358ea8a1c9
3
+ metadata.gz: 401cee25b17f0b8597e4b5d48158c123c11a0ea1
4
+ data.tar.gz: dbe23f829c09483393347486d5523f3a56d5a363
5
5
  SHA512:
6
- metadata.gz: 68d24fb420d824b7d1813d434c4e6e92e75d4580827fc5d9b190f06c15c8442b8feea31dc4342f84b52a1155a8033a9ca3c376abc5735fae3120d5894a833758
7
- data.tar.gz: 30603ad22a32e7fec26408ccbd78aaeedb09199d56fdc1152f54466fd24d15ef4c45258cf6a33fbb237fb6d96ab8fc6c90feccce5b4fd8756c379416982a76c8
6
+ metadata.gz: fb1a3db4d14ae50e54b89a44bce09e4b9dda4904e5892613031624d31c9a098d7780df3c762c3deb43a20640178c2346e85a909aed983f4b8c7eb18191112bd7
7
+ data.tar.gz: fd7c34424f9dd1579f155dffce8393b5457988517c28ccc2fea3801dd4f074e9adcc5e3bfc322e2e31af9bb7655fa80a9c44acf3269029bd70fc9dd987aed77e
data/Gemfile CHANGED
@@ -6,5 +6,7 @@ group :development do
6
6
  # We depend on Vagrant for development, but we don't add it as a
7
7
  # gem dependency because we expect to be installed within the
8
8
  # Vagrant environment itself using `vagrant plugin`.
9
- gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git"
9
+
10
+ # Can use for testing
11
+ # gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git"
10
12
  end
data/README.md CHANGED
@@ -2,8 +2,14 @@
2
2
 
3
3
  Vagrant Plugin allows for a better ansible flow also generates ansible inventory files, and runs playbooks
4
4
 
5
+
5
6
  ## Installation
6
7
 
8
+ `vagrant plugin install vagrant-flow`
9
+
10
+
11
+ Below is how to install as a regular gem which won't work
12
+
7
13
  Add this line to your application's Gemfile:
8
14
 
9
15
  gem 'vagrant-flow'
@@ -18,7 +24,7 @@ Or install it yourself as:
18
24
 
19
25
  ## Usage
20
26
 
21
- TODO: Write usage instructions here
27
+ `vagrant ansible-inventory`
22
28
 
23
29
  ## Contributing
24
30
 
@@ -29,6 +35,38 @@ TODO: Write usage instructions here
29
35
  5. Create new Pull Request
30
36
 
31
37
 
38
+ ## Development Flow
39
+
40
+ ```
41
+ # cd to vagrant-flow
42
+
43
+ # build the plugin
44
+
45
+ rake build
46
+
47
+ # install the plugin locally
48
+
49
+ vagrant plugin install pkg/vagrant-flow-1.0.3.gem
50
+
51
+ #
52
+ # use it and test
53
+ #
54
+
55
+ vagrant plugin uninstall vagrant-flow
56
+
57
+
58
+ #
59
+ # when done testing and ready to publish
60
+ #
61
+
62
+ rake release
63
+
64
+
65
+ # install for real from the repo
66
+
67
+ vagrant plugin vagrant-flow
68
+ ```
69
+
32
70
  # Background Research
33
71
 
34
72
  Vagrant Plugin List
@@ -54,4 +92,4 @@ rake build # It's a helper that will build your gem
54
92
  rake install # It's a helper that will build and install locally
55
93
  rake release # It's a helper that will push/release to rubygems
56
94
 
57
- ```
95
+ ```
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'bundler'
3
- # require 'bundler/setup' # Was in the example
3
+ require 'bundler/setup' # Was in the example
4
4
  require 'bundler/gem_tasks' # Was in the template version
5
5
 
6
6
  # Immediately sync all stdout so that tools like buildbot can
@@ -30,16 +30,16 @@ module VagrantPlugins
30
30
  o.separator ""
31
31
 
32
32
  # Don't use either of these, just keeping them here as examples of what options are possible
33
- o.on("--provision-with x,y,z", Array,
34
- "Enable only certain provisioners, by type.") do |list|
35
- options[:provision_types] = list.map { |type| type.to_sym }
36
- end
33
+ #o.on("--provision-with x,y,z", Array,
34
+ # "Enable only certain provisioners, by type.") do |list|
35
+ # options[:provision_types] = list.map { |type| type.to_sym }
36
+ #end
37
37
 
38
38
  # This option isn't used.
39
- o.on("--[no-]parallel",
40
- "Enable or disable parallelism if provider supports it.") do |parallel|
41
- options[:parallel] = parallel
42
- end
39
+ #o.on("--[no-]parallel",
40
+ # "Enable or disable parallelism if provider supports it.") do |parallel|
41
+ # options[:parallel] = parallel
42
+ #end
43
43
 
44
44
  end
45
45
 
@@ -57,22 +57,9 @@ module VagrantPlugins
57
57
  # Go over each VM and bring it up
58
58
  @logger.debug("'ansible-inventory' created for the whole env")
59
59
 
60
- # Example from the up command
61
-
62
- # Build up the batch job of what we'll do
63
- # @env.batch(options[:parallel]) do |batch|
64
- # with_target_vms(argv, :provider => options[:provider]) do |machine|
65
- # @env.ui.info(I18n.t(
66
- # "vagrant.commands.up.upping",
67
- # :name => machine.name,
68
- # :provider => machine.provider_name))
69
- #
70
- # batch.action(machine, :up, options)
71
- # end
72
- # end
73
-
74
60
 
75
61
 
62
+ provisioners = {}
76
63
  with_target_vms(argv, :provider => options[:provider]) do |machine|
77
64
  # @env.ui
78
65
  # output methods: :ask, :detail, :warn, :error, :info, :output, :success
@@ -90,15 +77,10 @@ module VagrantPlugins
90
77
  :forward_agent => ssh_info[:forward_agent],
91
78
  :forward_x11 => ssh_info[:forward_x11]
92
79
  }
93
-
94
80
  # Outputs to the stdout
95
- # @env.ui.info(machine.name)
96
-
97
- # From - Vagrant::Util::SafePuts
98
- # Template is erb
99
81
 
100
- # Implementation picks the first key
101
- # ssh_info[:private_key_path] returns an array
82
+ #The provisioning information from teh vagrant file, this will contain our defined ansible groups
83
+ provisioners = machine.config.vm.provisioners
102
84
 
103
85
  inventory_configs = {
104
86
  :vagrant_file_dir => machine.env.root_path,
@@ -106,108 +88,72 @@ module VagrantPlugins
106
88
  }
107
89
 
108
90
  machines_configs[variables[:host_key]]= variables
109
-
110
- # ansible_template = '<%= host_key %> ansible_ssh_host=<%= ssh_host %> ansible_ssh_port=<%= ssh_port %> ansible_ssh_user=<%= ssh_user %> ansible_ssh_private_key_file=<%= private_key_path[0] %> # Machine Name: <%= host_key %>'
111
- # safe_puts(Vagrant::Util::TemplateRenderer.render_string(ansible_template, variables))
112
-
113
91
  end
114
92
 
93
+
94
+ # Outputs to the stdout
95
+ # @env.ui.info(machine.name)
96
+
97
+ # From - Vagrant::Util::SafePuts
98
+ # Template is erb
99
+
100
+ # Implementation picks the first key
101
+ # ssh_info[:private_key_path] returns an array
102
+
103
+ #outputs is going to contain our strings that are the formatted ansible configs
104
+ #the key will be the vm name, the value will the be formatted sring
105
+ outputs = {}
106
+
115
107
  inventory_configs[:vagrant_flow_file].open('w') do |file|
116
- header_txt="# Generated by vagrant-flow, part of NeverwinterDP\n\n"
117
- safe_puts(header_txt)
118
- file.write(header_txt)
119
108
  machines_configs.each do |host, variables|
120
109
  ansible_template = '<%= host_key %> ansible_ssh_host=<%= ssh_host %> ansible_ssh_port=<%= ssh_port %> ansible_ssh_user=<%= ssh_user %> ansible_ssh_private_key_file=<%= private_key_path[0] %> # Machine Name: <%= host_key %>'
121
- host_txt=Vagrant::Util::TemplateRenderer.render_string(ansible_template, variables)
122
- safe_puts(host_txt)
123
- file.write("#{host_txt}\n")
110
+ outputs[variables[:host_key]] = Vagrant::Util::TemplateRenderer.render_string(ansible_template, variables)
111
+ #safe_puts(host_txt)
112
+ #file.write("#{host_txt}\n")
124
113
  end
125
114
  end
126
115
 
127
- # Test writing the the path variables out.
128
- # safe_puts("vagrant_file_dir: #{inventory_configs[:vagrant_file_dir]}")
129
- # safe_puts("vagrant_flow_file: #{inventory_configs[:vagrant_flow_file]}")
130
-
131
-
132
-
133
- # Give it machine from with_target_vms
134
- # def setup_inventory_file(machine)
135
- # return config.inventory_path if config.inventory_path
136
- #
137
- # ssh = machine.ssh_info
138
- #
139
- # generated_inventory_file =
140
- # machine.env.root_path.join("vagrant_ansible_inventory_#{machine.name}")
141
- #
142
- # generated_inventory_file.open('w') do |file|
143
- # file.write("# Generated by Vagrant\n\n")
144
- # file.write("#{machine.name} ansible_ssh_host=#{ssh[:host]} ansible_ssh_port=#{ssh[:port]}\n")
145
- #
146
- # # Write out groups information. Only include current
147
- # # machine and its groups to avoid Ansible errors on
148
- # # provisioning.
149
- # groups_of_groups = {}
150
- # included_groups = []
151
- #
152
- # config.groups.each_pair do |gname, gmembers|
153
- # if gname.end_with?(":children")
154
- # groups_of_groups[gname] = gmembers
155
- # elsif gmembers.include?("#{machine.name}")
156
- # included_groups << gname
157
- # file.write("\n[#{gname}]\n")
158
- # file.write("#{machine.name}\n")
159
- # end
160
- # end
161
- #
162
- # groups_of_groups.each_pair do |gname, gmembers|
163
- # unless (included_groups & gmembers).empty?
164
- # file.write("\n[#{gname}]\n")
165
- # gmembers.each do |gm|
166
- # file.write("#{gm}\n") if included_groups.include?(gm)
167
- # end
168
- # end
169
- # end
170
- # end
171
- #
172
- # return generated_inventory_file.to_s
173
- # end
174
-
175
- # Documentation Ahead is from:
176
- # http://docs.ansible.com/intro_inventory.html
177
-
178
- # ansible_ssh_host
179
- # The name of the host to connect to, if different from the alias you wish to give to it.
180
- # ansible_ssh_port
181
- # The ssh port number, if not 22
182
- # ansible_ssh_user
183
- # The default ssh user name to use.
184
- # ansible_ssh_pass
185
- # The ssh password to use (this is insecure, we strongly recommend using --ask-pass or SSH keys)
186
- # ansible_sudo_pass
187
- # The sudo password to use (this is insecure, we strongly recommend using --ask-sudo-pass)
188
- # ansible_connection
189
- # Connection type of the host. Candidates are local, ssh or paramiko. The default is paramiko before Ansible 1.2, and 'smart' afterwards which detects whether usage of 'ssh' would be feasible based on whether ControlPersist is supported.
190
- # ansible_ssh_private_key_file
191
- # Private key file used by ssh. Useful if using multiple keys and you don't want to use SSH agent.
192
- # ansible_python_interpreter
193
- # The target host python path. This is useful for systems with more
194
- # than one Python or not located at "/usr/bin/python" such as \*BSD, or where /usr/bin/python
195
- # is not a 2.X series Python. We do not use the "/usr/bin/env" mechanism as that requires the remote user's
196
- # path to be set right and also assumes the "python" executable is named python, where the executable might
197
- # be named something like "python26".
198
- # ansible\_\*\_interpreter
199
- # Works for anything such as ruby or perl and works just like ansible_python_interpreter.
200
- # This replaces shebang of modules which will run on that host.
201
-
202
-
203
- # Success, exit status 0
204
-
205
-
116
+ #require 'pp'
117
+ #puts "PROVISIONERS"
118
+ #PP.pp(provisioners)
119
+ #puts "OUTPUTS"
120
+ #PP.pp(outputs)
121
+ #puts "\n\n"
206
122
 
123
+ inventory_configs[:vagrant_flow_file].open('w') do |file|
124
+ header_txt="# Generated by vagrant-flow, part of NeverwinterDP\n\n"
125
+ safe_puts(header_txt)
126
+ file.write(header_txt)
127
+
128
+ #Now we maps from our VAGRANTFILE defined groups in our provisioners.config.groups
129
+ #To our configuration strings we got from outputs
130
+ provisioners.each do |prov|
131
+ prov.config.groups.each do |groupname,machines|
132
+ puts "["+groupname+"]\n"
133
+ file.write "["+groupname+"]\n"
134
+ machines.each do |machinename|
135
+ #if we match :children, then we have an ansible config that's
136
+ #pointing to another group, not a specific machine
137
+ if /:children/.match(groupname)
138
+ puts machinename
139
+ file.write machinename+"\n"
140
+ else
141
+ puts outputs[machinename.to_sym]+"\n"
142
+ file.write outputs[machinename.to_sym]+"\n"
143
+ end
144
+ end
145
+ puts "\n"
146
+ file.write "\n"
147
+ end
148
+ end
149
+ end
207
150
  0
208
151
  end # End Execute
209
152
 
210
153
 
154
+ # Documentation reference
155
+ # http://docs.ansible.com/intro_inventory.html
156
+
211
157
  def setup_inventory_file(machine)
212
158
  return machine.config.inventory_path if machine.config.inventory_path
213
159
 
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module VagrantFlow
3
- VERSION = "1.0.2"
3
+ VERSION = "1.0.4"
4
4
  end
5
5
  end
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.2
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Morin