pauper 0.2.2 → 0.2.3
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 +15 -0
- data/bin/pauper +23 -42
- data/lib/fusion.rb +21 -2
- data/lib/pauper.rb +46 -9
- data/lib/pauper/version.rb +1 -1
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 589978903d478bbfdf3beb1be05ecfbb6fb70bf7
|
4
|
+
data.tar.gz: 8233aa486d0ec6198bbba31fadce7d548718b2eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d7d522f39270b10f2d5485ba6a2553e4c9cb45984e8c689556964226957bd27a37cd4d876c0f4199ac543552e0cb3f3c8eb3703bbe1ba63633270ef36c3e414
|
7
|
+
data.tar.gz: 33e72c961f56f25bace2f933455dce6532dc73ecc32feb0172a9fce3400c5f2779d1890219721dee2298b1b66d36114cc1fb7b155d955d0525a29153ca8fb474
|
data/README.md
CHANGED
@@ -77,6 +77,19 @@ haveged generates the needed entropy for you and should slove this issue. Feel
|
|
77
77
|
free to `kill` haveged when you are done (it will run forever, hiding in the
|
78
78
|
background if you do not :P )
|
79
79
|
|
80
|
+
Upgrading
|
81
|
+
-------------------------------------------------------------------------------
|
82
|
+
To update the Pauper gem from your local files:
|
83
|
+
|
84
|
+
```
|
85
|
+
rake install
|
86
|
+
```
|
87
|
+
|
88
|
+
To update the Pauper gem from RubyGems:
|
89
|
+
|
90
|
+
```
|
91
|
+
gem update pauper
|
92
|
+
```
|
80
93
|
|
81
94
|
TIPS
|
82
95
|
--------------------------------------------------------------------------------
|
@@ -89,6 +102,7 @@ If this script does not exist you may have to pull master or if you
|
|
89
102
|
would prefer to do it the hard way...
|
90
103
|
|
91
104
|
OSX users:
|
105
|
+
|
92
106
|
1. SSH into your VM
|
93
107
|
2. `cd` into your `pauper-env` directory
|
94
108
|
3. `pauper stop`
|
@@ -100,3 +114,4 @@ OSX users:
|
|
100
114
|
9. `pauper setup_osx`
|
101
115
|
|
102
116
|
This will hopefully get you into a happy state... Hopefully...
|
117
|
+
|
data/bin/pauper
CHANGED
@@ -1,38 +1,28 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require 'rubygems'
|
4
3
|
require 'thor'
|
5
4
|
require 'pauper'
|
6
5
|
require 'fusion'
|
7
6
|
|
8
|
-
#
|
9
|
-
|
7
|
+
# ignore the earlier opt-out-time flag
|
10
8
|
SKIP_VERSION_CHECK_FLAG = '--skip-version-check'
|
11
|
-
unless ARGV.include?(SKIP_VERSION_CHECK_FLAG)
|
12
|
-
current_version = Gem.loaded_specs['pauper'].version
|
13
|
-
latest_version = Gem.latest_version_for('pauper')
|
14
|
-
if current_version < latest_version
|
15
|
-
puts "It's your lucky day! There's a new version of Pauper available. You're on #{current_version}. Latest is #{latest_version}."
|
16
|
-
puts "You can skip this check with the #{SKIP_VERSION_CHECK_FLAG} flag, if you really must."
|
17
|
-
exit
|
18
|
-
end
|
19
|
-
end
|
20
9
|
ARGV.delete(SKIP_VERSION_CHECK_FLAG)
|
21
10
|
|
22
11
|
# Make sure PATH is what ubuntu expects it to be
|
23
12
|
ENV['PATH']='/usr/local/sbin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin'
|
24
13
|
|
25
|
-
require 'vmx'
|
26
|
-
|
27
14
|
module Pauperism
|
28
15
|
class Vm < Thor
|
29
|
-
class_option :vmpath, :type => :string
|
30
|
-
class_option :vmrunpath, :type => :string # TODO: implement
|
31
|
-
|
32
16
|
no_commands do
|
33
|
-
def
|
34
|
-
|
35
|
-
|
17
|
+
def pauper
|
18
|
+
return @pauper if @pauper
|
19
|
+
pauperfile = File.expand_path(options[:pauperfile]) if options[:pauperfile]
|
20
|
+
@pauper = Pauper.new(true, pauperfile)
|
21
|
+
end
|
22
|
+
|
23
|
+
def fusion
|
24
|
+
return @fusion if @fusion
|
25
|
+
@fusion = Fusion.new(pauper.config.config[:vm_path])
|
36
26
|
end
|
37
27
|
end
|
38
28
|
|
@@ -159,37 +149,22 @@ module Pauperism
|
|
159
149
|
pauper.write_hosts
|
160
150
|
end
|
161
151
|
|
162
|
-
desc 'setup_osx
|
163
|
-
def setup_osx
|
152
|
+
desc 'setup_osx', 'Set up things for OS X'
|
153
|
+
def setup_osx
|
164
154
|
unless Pauper.osx?
|
165
155
|
puts 'Not OSX! I refuse!'
|
166
156
|
exit
|
167
157
|
end
|
168
158
|
pauper(true)
|
169
159
|
|
170
|
-
vmx_file = Fusion.new(vm_path).vmx
|
171
|
-
vmx = VMX.new(vmx_file)
|
172
|
-
|
173
|
-
mac = vmx.data['ethernet0.generatedAddress']
|
174
|
-
arpmac = mac.gsub(/0([0-9a-fA-F])/, '\1') # switch it to the format that arp likes
|
175
|
-
|
176
|
-
match = `arp -a | grep -i #{arpmac}`.match(/\(([0-9.]+)\)/)
|
177
|
-
unless match
|
178
|
-
puts "Could not find any running VM with MAC addr: #{arpmac}"
|
179
|
-
puts " >> Manually SSH into the VM then try again <<"
|
180
|
-
exit
|
181
|
-
end
|
182
|
-
|
183
|
-
ip = match.captures[0]
|
184
|
-
|
185
160
|
# Set up DHCPD
|
186
|
-
pauper.setup_osx_dhcpd(mac, ip)
|
161
|
+
pauper.setup_osx_dhcpd(fusion.mac, fusion.ip)
|
187
162
|
|
188
163
|
# Set up route
|
189
|
-
pauper.setup_osx_routes(ip)
|
164
|
+
pauper.setup_osx_routes(fusion.ip)
|
190
165
|
|
191
166
|
# Write hosts
|
192
|
-
pauper.write_osx_hosts(ip)
|
167
|
+
pauper.write_osx_hosts(fusion.ip)
|
193
168
|
end
|
194
169
|
|
195
170
|
desc "up", "Start all nodes on your vm from local!"
|
@@ -209,9 +184,15 @@ module Pauperism
|
|
209
184
|
end
|
210
185
|
|
211
186
|
no_commands do
|
212
|
-
def pauper(ignore_network=false
|
187
|
+
def pauper(ignore_network=false)
|
188
|
+
return @pauper if @pauper
|
213
189
|
pauperfile = File.expand_path(options[:pauperfile]) if options[:pauperfile]
|
214
|
-
@pauper
|
190
|
+
@pauper = Pauper.new(ignore_network, pauperfile)
|
191
|
+
end
|
192
|
+
|
193
|
+
def fusion
|
194
|
+
return @fusion if @fusion
|
195
|
+
@fusion = Fusion.new(pauper.config.config[:vm_path])
|
215
196
|
end
|
216
197
|
end
|
217
198
|
|
data/lib/fusion.rb
CHANGED
@@ -99,9 +99,9 @@ class Fusion
|
|
99
99
|
puts "I can't find your VM. Try passing in a path to the <name>.vmwarevm dir."
|
100
100
|
exit
|
101
101
|
elsif vms.size > 1
|
102
|
-
puts "I'm not sure which VM I should use! Try
|
102
|
+
puts "I'm not sure which VM I should use! Try adding one of these to your Pauperfile:"
|
103
103
|
vms.each do |vm|
|
104
|
-
puts "\
|
104
|
+
puts "\tvm_path \"#{vm}\""
|
105
105
|
end
|
106
106
|
exit
|
107
107
|
end
|
@@ -109,4 +109,23 @@ class Fusion
|
|
109
109
|
# Return .vmx file
|
110
110
|
Dir[vms[0] + '/*.vmx'][0]
|
111
111
|
end
|
112
|
+
|
113
|
+
def ip
|
114
|
+
# switch mac to the format that arp likes
|
115
|
+
arpmac = mac.gsub(/0([0-9a-fA-F])/, '\1')
|
116
|
+
|
117
|
+
match = `arp -a | grep -i #{arpmac}`.match(/\(([0-9.]+)\)/)
|
118
|
+
unless match
|
119
|
+
puts "Could not find any running VM with MAC addr: #{arpmac}"
|
120
|
+
puts " >> Manually SSH into the VM then try again <<"
|
121
|
+
exit
|
122
|
+
end
|
123
|
+
|
124
|
+
return match.captures[0]
|
125
|
+
end
|
126
|
+
|
127
|
+
def mac
|
128
|
+
vmx = VMX.new(self.vmx)
|
129
|
+
return vmx.data['ethernet0.generatedAddress']
|
130
|
+
end
|
112
131
|
end
|
data/lib/pauper.rb
CHANGED
@@ -22,7 +22,8 @@ class Pauper
|
|
22
22
|
DEFAULT_VM_PATH = File.expand_path('/var/lib/lxc/')
|
23
23
|
SUPPORTED_RELEASES = [:lucid, :precise]
|
24
24
|
|
25
|
-
def initialize(ignore_network = false, pauperfile =
|
25
|
+
def initialize(ignore_network = false, pauperfile = nil)
|
26
|
+
pauperfile = DEFAULT_PAUPERFILE if pauperfile.nil?
|
26
27
|
if root?
|
27
28
|
puts "Don't run as root!"
|
28
29
|
exit
|
@@ -30,6 +31,28 @@ class Pauper
|
|
30
31
|
|
31
32
|
@pauper_config = Pauper::Config.new(pauperfile)
|
32
33
|
setup_network unless ignore_network
|
34
|
+
check_for_new_version
|
35
|
+
end
|
36
|
+
|
37
|
+
def check_for_new_version
|
38
|
+
begin
|
39
|
+
settings = pauper_settings()
|
40
|
+
rescue NoMethodError
|
41
|
+
settings = {skip_version_check: false}
|
42
|
+
end
|
43
|
+
unless settings[:skip_version_check]
|
44
|
+
current_version = Gem.loaded_specs['pauper'].version
|
45
|
+
latest_version = Gem.latest_version_for('pauper')
|
46
|
+
if current_version < latest_version
|
47
|
+
puts
|
48
|
+
puts "***************************************************************"
|
49
|
+
puts "It's your lucky day! There's a new version of Pauper available."
|
50
|
+
puts "You're on #{current_version}. Latest is #{latest_version}."
|
51
|
+
puts "***************************************************************"
|
52
|
+
puts
|
53
|
+
exit 1
|
54
|
+
end
|
55
|
+
end
|
33
56
|
end
|
34
57
|
|
35
58
|
def root?
|
@@ -105,10 +128,6 @@ class Pauper
|
|
105
128
|
stop_node(base_name)
|
106
129
|
end
|
107
130
|
|
108
|
-
def username
|
109
|
-
ENV['USER']
|
110
|
-
end
|
111
|
-
|
112
131
|
def ssh_key
|
113
132
|
@ssh_key ||= begin
|
114
133
|
key = @pauper_config.config[:bootstrap_ssh_key] || "/home/#{username}/.ssh/id_rsa"
|
@@ -237,7 +256,7 @@ EOF
|
|
237
256
|
}.merge(config[:chef_options]).merge(node_config.config[:chef_options])
|
238
257
|
|
239
258
|
puts "Uploading Chef files..."
|
240
|
-
Net::SCP.start ip,
|
259
|
+
Net::SCP.start ip, username do |scp|
|
241
260
|
scp.upload! tmp_client_rb_path, "client.rb"
|
242
261
|
scp.upload! config[:validation_key_path], "validation.pem"
|
243
262
|
scp.upload! StringIO.new(chef_attribs.to_json), "client-config.json"
|
@@ -246,7 +265,7 @@ EOF
|
|
246
265
|
FileUtils.rm(tmp_client_rb_path)
|
247
266
|
|
248
267
|
puts "Connecting over SSH..."
|
249
|
-
Net::SSH.start ip,
|
268
|
+
Net::SSH.start ip, username do |ssh|
|
250
269
|
ssh_exec ssh, "sudo mv client.rb /etc/chef/"
|
251
270
|
ssh_exec ssh, "sudo mv validation.pem /etc/chef/"
|
252
271
|
ssh_exec ssh, "sudo mv client-config.json /etc/chef/"
|
@@ -364,8 +383,16 @@ EOF
|
|
364
383
|
end
|
365
384
|
|
366
385
|
def start_all
|
386
|
+
skipped = Array.new
|
367
387
|
puts "Starting all nodes..."
|
368
|
-
@pauper_config.config[:nodes].each
|
388
|
+
@pauper_config.config[:nodes].each do |n|
|
389
|
+
if n.config[:optional]
|
390
|
+
skipped << n.name
|
391
|
+
else
|
392
|
+
start(n.name) unless n.config[:optional]
|
393
|
+
end
|
394
|
+
end
|
395
|
+
puts "Skipped: [#{skipped.join(', ')}]" unless skipped.empty?
|
369
396
|
end
|
370
397
|
|
371
398
|
def stop_all
|
@@ -466,7 +493,7 @@ EOF
|
|
466
493
|
'Enter passphrase for '] # key waiting for password...
|
467
494
|
puts "\e[32m====> SSH >===="
|
468
495
|
lines = 0
|
469
|
-
Net::SSH.start ip,
|
496
|
+
Net::SSH.start ip, username, {:forward_agent => true} do |ssh|
|
470
497
|
ssh.open_channel do |channel|
|
471
498
|
channel.request_pty do |ch, success| # Needed for password responses
|
472
499
|
abort('Failed to get pty...') unless success
|
@@ -633,6 +660,7 @@ EOF
|
|
633
660
|
:nodes => [],
|
634
661
|
:ssh_user => 'dev',
|
635
662
|
:ssh_password => 'password',
|
663
|
+
:vm_path => Fusion::DEFAULT_VMPATH,
|
636
664
|
:run_list => [],
|
637
665
|
:shares => [],
|
638
666
|
:subnet => '172.16.254',
|
@@ -675,6 +703,10 @@ EOF
|
|
675
703
|
@config[:subnet] = net
|
676
704
|
end
|
677
705
|
|
706
|
+
def vm_path(path)
|
707
|
+
@config[:vm_path] = File.expand_path(path)
|
708
|
+
end
|
709
|
+
|
678
710
|
def vmx(vmx_file)
|
679
711
|
@config[:vmx] = File.expand_path(vmx_file)
|
680
712
|
end
|
@@ -745,6 +777,7 @@ EOF
|
|
745
777
|
:run_list => [],
|
746
778
|
:chef_options => {},
|
747
779
|
:release => :lucid,
|
780
|
+
:optional => false,
|
748
781
|
}
|
749
782
|
instance_eval &block
|
750
783
|
end
|
@@ -776,6 +809,10 @@ EOF
|
|
776
809
|
def release(release_s)
|
777
810
|
@config[:release] = Pauper.grok_release(release_s)
|
778
811
|
end
|
812
|
+
|
813
|
+
def optional(v=true)
|
814
|
+
@config[:optional] = v
|
815
|
+
end
|
779
816
|
end
|
780
817
|
end
|
781
818
|
end
|
data/lib/pauper/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pauper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler McMullen
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-04-
|
12
|
+
date: 2014-04-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
@@ -116,4 +116,3 @@ summary: A semi-sane way to manage a multi-vm dev environment
|
|
116
116
|
test_files:
|
117
117
|
- test/pauper_test.rb
|
118
118
|
- test/test_helper.rb
|
119
|
-
has_rdoc:
|