barking_iguana-compound 0.1.7 → 0.1.8
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/docs/CHANGELOG.md +11 -1
- data/docs/TODO.md +0 -2
- data/examples/simple/Gemfile +4 -0
- data/examples/simple/Gemfile.lock +102 -0
- data/examples/simple/Rakefile +3 -0
- data/examples/simple/test/compound/simple/000-setup/example-host/example_spec.rb +5 -0
- data/examples/simple/test/compound/simple/000-setup/playbook.yml +11 -0
- data/examples/simple/test/compound/simple/Vagrantfile +18 -0
- data/examples/simple/test/compound/simple/inventory +2 -0
- data/lib/barking_iguana/compound/ansible/playbook.rb +0 -2
- data/lib/barking_iguana/compound/host.rb +8 -0
- data/lib/barking_iguana/compound/server_spec.rb +53 -55
- data/lib/barking_iguana/compound/test.rb +4 -5
- data/lib/barking_iguana/compound/test_stage.rb +9 -21
- data/lib/barking_iguana/compound/vagrant.rb +96 -93
- data/lib/barking_iguana/compound/version.rb +1 -1
- data/lib/barking_iguana/compound.rb +1 -0
- data/resources/Vagrantfile.erb +1 -1
- data/resources/spec_helper.rb +6 -0
- metadata +11 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 782a866b326abf184c9162aa9bdc809eccac06ec
|
|
4
|
+
data.tar.gz: c687db95a7f2f3e6b27319f1f984f630764eefb0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3ccb56d7df5ea74e60c6d6d75212d7961c38933e1fa526b2b6efee21a8b06952fcd4e65dd4f40ee1f786b3547c1f37c90e6d330f073b1db9b22427cc73272f3a
|
|
7
|
+
data.tar.gz: 783f362384a91262ea0a08166b24bf3b3233790473e92816a7ebdbf8f6a133b556f3bd804f04c6d1b7e09539b69434ef45a1acd822b0d97c347e84fe3374b0d9
|
data/docs/CHANGELOG.md
CHANGED
|
@@ -2,10 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
Entries are in reverse chronological order.
|
|
4
4
|
|
|
5
|
-
## *0.1.
|
|
5
|
+
## *0.1.9* (Current Development)
|
|
6
6
|
|
|
7
7
|
Add release notes here, as things are added to the project.
|
|
8
8
|
|
|
9
|
+
## *0.1.8* (2017-01-08)
|
|
10
|
+
|
|
11
|
+
* Clean up the generated inventory after the test has run.
|
|
12
|
+
|
|
13
|
+
* Add a simple example in lieu of tests.
|
|
14
|
+
|
|
15
|
+
* Code clean-up including using `Forwardable` to avoid lots of tiny
|
|
16
|
+
forwarding methods, and correctly namespacing the `ServerSpec` and
|
|
17
|
+
`Vagrant` classes. Sorry for polluting your programmes!
|
|
18
|
+
|
|
9
19
|
## *0.1.7* (2017-01-06)
|
|
10
20
|
|
|
11
21
|
* Allow setting the Vagrantfile.erb template in the root of the test suite to
|
data/docs/TODO.md
CHANGED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: ../../
|
|
3
|
+
specs:
|
|
4
|
+
barking_iguana-compound (0.1.7)
|
|
5
|
+
ansible_spec
|
|
6
|
+
barking_iguana-benchmark
|
|
7
|
+
barking_iguana-logging
|
|
8
|
+
colorize
|
|
9
|
+
hostlist_expression
|
|
10
|
+
mixlib-shellout
|
|
11
|
+
oj
|
|
12
|
+
rspec-wait
|
|
13
|
+
|
|
14
|
+
GEM
|
|
15
|
+
remote: http://rubygems.org/
|
|
16
|
+
specs:
|
|
17
|
+
ansible_spec (0.2.16)
|
|
18
|
+
hostlist_expression
|
|
19
|
+
oj
|
|
20
|
+
serverspec (>= 2.0.0)
|
|
21
|
+
winrm
|
|
22
|
+
barking_iguana-benchmark (0.1.0)
|
|
23
|
+
barking_iguana-logging (0.1.5)
|
|
24
|
+
barking_iguana-otk
|
|
25
|
+
term-ansicolor
|
|
26
|
+
barking_iguana-otk (0.1.0)
|
|
27
|
+
builder (3.2.2)
|
|
28
|
+
colorize (0.8.1)
|
|
29
|
+
diff-lcs (1.2.5)
|
|
30
|
+
erubis (2.7.0)
|
|
31
|
+
ffi (1.9.14)
|
|
32
|
+
gssapi (1.2.0)
|
|
33
|
+
ffi (>= 1.0.1)
|
|
34
|
+
gyoku (1.3.1)
|
|
35
|
+
builder (>= 2.1.2)
|
|
36
|
+
hostlist_expression (0.2.1)
|
|
37
|
+
httpclient (2.8.3)
|
|
38
|
+
little-plugger (1.1.4)
|
|
39
|
+
logging (2.1.0)
|
|
40
|
+
little-plugger (~> 1.1)
|
|
41
|
+
multi_json (~> 1.10)
|
|
42
|
+
mixlib-shellout (2.2.7)
|
|
43
|
+
multi_json (1.12.1)
|
|
44
|
+
net-scp (1.2.1)
|
|
45
|
+
net-ssh (>= 2.6.5)
|
|
46
|
+
net-ssh (3.2.0)
|
|
47
|
+
net-telnet (0.1.1)
|
|
48
|
+
nori (2.6.0)
|
|
49
|
+
oj (2.18.0)
|
|
50
|
+
rake (12.0.0)
|
|
51
|
+
rspec (3.5.0)
|
|
52
|
+
rspec-core (~> 3.5.0)
|
|
53
|
+
rspec-expectations (~> 3.5.0)
|
|
54
|
+
rspec-mocks (~> 3.5.0)
|
|
55
|
+
rspec-core (3.5.4)
|
|
56
|
+
rspec-support (~> 3.5.0)
|
|
57
|
+
rspec-expectations (3.5.0)
|
|
58
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
59
|
+
rspec-support (~> 3.5.0)
|
|
60
|
+
rspec-its (1.2.0)
|
|
61
|
+
rspec-core (>= 3.0.0)
|
|
62
|
+
rspec-expectations (>= 3.0.0)
|
|
63
|
+
rspec-mocks (3.5.0)
|
|
64
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
65
|
+
rspec-support (~> 3.5.0)
|
|
66
|
+
rspec-support (3.5.0)
|
|
67
|
+
rspec-wait (0.0.9)
|
|
68
|
+
rspec (>= 3, < 4)
|
|
69
|
+
rubyntlm (0.6.1)
|
|
70
|
+
serverspec (2.37.2)
|
|
71
|
+
multi_json
|
|
72
|
+
rspec (~> 3.0)
|
|
73
|
+
rspec-its
|
|
74
|
+
specinfra (~> 2.53)
|
|
75
|
+
sfl (2.3)
|
|
76
|
+
specinfra (2.66.3)
|
|
77
|
+
net-scp
|
|
78
|
+
net-ssh (>= 2.7, < 4.0)
|
|
79
|
+
net-telnet
|
|
80
|
+
sfl
|
|
81
|
+
term-ansicolor (1.4.0)
|
|
82
|
+
tins (~> 1.0)
|
|
83
|
+
tins (1.13.0)
|
|
84
|
+
winrm (2.1.1)
|
|
85
|
+
builder (>= 2.1.2)
|
|
86
|
+
erubis (~> 2.7)
|
|
87
|
+
gssapi (~> 1.2)
|
|
88
|
+
gyoku (~> 1.0)
|
|
89
|
+
httpclient (~> 2.2, >= 2.2.0.2)
|
|
90
|
+
logging (>= 1.6.1, < 3.0)
|
|
91
|
+
nori (~> 2.0)
|
|
92
|
+
rubyntlm (~> 0.6.0, >= 0.6.1)
|
|
93
|
+
|
|
94
|
+
PLATFORMS
|
|
95
|
+
ruby
|
|
96
|
+
|
|
97
|
+
DEPENDENCIES
|
|
98
|
+
barking_iguana-compound!
|
|
99
|
+
rake
|
|
100
|
+
|
|
101
|
+
BUNDLED WITH
|
|
102
|
+
1.13.6
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Vagrant.configure(2) do |config|
|
|
2
|
+
config.vm.box = "bento/ubuntu-16.10"
|
|
3
|
+
config.vm.box_check_update = false
|
|
4
|
+
config.vm.provider "virtualbox" do |vb|
|
|
5
|
+
vb.memory = "512"
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
config.vm.define "example-host" do |this|
|
|
10
|
+
this.vm.hostname = "example-host"
|
|
11
|
+
this.vm.network "private_network", ip: "10.8.42.10"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
config.ssh.username = "vagrant"
|
|
16
|
+
config.ssh.password = "vagrant"
|
|
17
|
+
config.ssh.insert_key = false
|
|
18
|
+
end
|
|
@@ -66,8 +66,6 @@ module BarkingIguana
|
|
|
66
66
|
FileUtils.remove_file wrapper_playbook, true
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
-
# TODO: Symlink the playbook to wrapper_playbook.path
|
|
70
|
-
# so we can use the group_vars, host_vars, etc.
|
|
71
69
|
def playbook_paths
|
|
72
70
|
return file unless run_from
|
|
73
71
|
tempfile = wrapper_playbook
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
module BarkingIguana
|
|
2
2
|
module Compound
|
|
3
3
|
class Host
|
|
4
|
+
extend Forwardable
|
|
5
|
+
|
|
4
6
|
attr_accessor :inventory_name, :ip_address, :state
|
|
5
7
|
|
|
6
8
|
def initialize(name:, ip_address:)
|
|
@@ -33,6 +35,12 @@ module BarkingIguana
|
|
|
33
35
|
def ssh_extra_args
|
|
34
36
|
'-o StrictHostKeyChecking=no'
|
|
35
37
|
end
|
|
38
|
+
|
|
39
|
+
def_delegator :inventory_name, :hash
|
|
40
|
+
|
|
41
|
+
def eql? other
|
|
42
|
+
inventory_name == other.inventory_name
|
|
43
|
+
end
|
|
36
44
|
end
|
|
37
45
|
end
|
|
38
46
|
end
|
|
@@ -1,66 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
module BarkingIguana
|
|
2
|
+
module Compound
|
|
3
|
+
class ServerSpec
|
|
4
|
+
extend Forwardable
|
|
5
|
+
attr_accessor :stage
|
|
3
6
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
include BarkingIguana::Logging::Helper
|
|
9
|
-
include BarkingIguana::Benchmark
|
|
10
|
-
|
|
11
|
-
def run
|
|
12
|
-
logger.debug { "Host tests: #{host_tests.inspect}" }
|
|
13
|
-
host_tests.each do |host_name, test_files|
|
|
14
|
-
command = "bundle exec ruby -S rspec -r #{control_repo_dir}/library/spec_helper.rb #{test_files.join(' ')}"
|
|
15
|
-
c = Mixlib::ShellOut.new command, live_stream: logger, cwd: control_repo_dir, env: env_for(host_name)
|
|
16
|
-
benchmark command do
|
|
17
|
-
c.run_command
|
|
7
|
+
def initialize stage
|
|
8
|
+
self.stage = stage
|
|
18
9
|
end
|
|
19
|
-
c.error!
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def control_repo_dir
|
|
24
|
-
stage.test.suite.control_directory
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def host_for host_test
|
|
28
|
-
stage.test.host_manager.find_by_name host_test['name']
|
|
29
|
-
end
|
|
30
10
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
raise "Could not find host #{host_test} in inventory #{hosts.inspect}" unless host
|
|
34
|
-
# TODO: Keep these in the host object
|
|
35
|
-
{
|
|
36
|
-
TARGET_HOST: host['uri'],
|
|
37
|
-
TARGET_SSH_USER: 'vagrant',
|
|
38
|
-
TARGET_SSH_KEY: "#{ENV['HOME']}/.vagrant.d/insecure_private_key"
|
|
39
|
-
}
|
|
40
|
-
end
|
|
11
|
+
include BarkingIguana::Logging::Helper
|
|
12
|
+
include BarkingIguana::Benchmark
|
|
41
13
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
14
|
+
def run
|
|
15
|
+
logger.debug { "Host tests: #{host_tests.inspect}" }
|
|
16
|
+
host_tests.each do |host, test_files|
|
|
17
|
+
command = "bundle exec ruby -S rspec -r #{spec_helper} #{test_files.join(' ')}"
|
|
18
|
+
c = Mixlib::ShellOut.new command, live_stream: logger, cwd: control_repo_dir, env: env_for(host)
|
|
19
|
+
benchmark command do
|
|
20
|
+
c.run_command
|
|
21
|
+
end
|
|
22
|
+
logger.info { "#{host.name} tests exited with status #{c.exitstatus}" }
|
|
23
|
+
c.error!
|
|
24
|
+
end
|
|
25
|
+
end
|
|
45
26
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
27
|
+
def env_for host
|
|
28
|
+
{
|
|
29
|
+
TARGET_HOST: host.ip_address,
|
|
30
|
+
TARGET_SSH_USER: host.ssh_username,
|
|
31
|
+
TARGET_SSH_KEY: host.ssh_key
|
|
32
|
+
}
|
|
33
|
+
end
|
|
49
34
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
35
|
+
def host_tests
|
|
36
|
+
hosts.inject({}) do |a,e|
|
|
37
|
+
name = e.name
|
|
38
|
+
glob = "#{root_dir}/{#{name}/**/*_,}spec.rb"
|
|
39
|
+
logger.debug { "Host glob for #{name.inspect} = #{glob.inspect}" }
|
|
40
|
+
tests = Dir.glob glob
|
|
41
|
+
logger.debug { "Host tests for #{name.inspect} = #{tests.inspect}" }
|
|
42
|
+
if !tests.empty?
|
|
43
|
+
if e.state != 'running'
|
|
44
|
+
raise "There are tests for #{name} in #{stage.stage_directory}, but the host is #{e.state}"
|
|
45
|
+
end
|
|
46
|
+
a[e] = tests
|
|
47
|
+
end
|
|
48
|
+
a
|
|
60
49
|
end
|
|
61
|
-
a[e] = tests
|
|
62
50
|
end
|
|
63
|
-
|
|
51
|
+
|
|
52
|
+
def spec_helper
|
|
53
|
+
File.expand_path '../../../../resources/spec_helper.rb', __FILE__
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def_delegator :stage, :test
|
|
57
|
+
def_delegator :stage, :stage_directory, :root_dir
|
|
58
|
+
def_delegator :test, :suite
|
|
59
|
+
def_delegator :suite, :control_directory, :control_repo_dir
|
|
60
|
+
def_delegator :test, :host_manager
|
|
61
|
+
def_delegator :host_manager, :all, :hosts
|
|
64
62
|
end
|
|
65
63
|
end
|
|
66
64
|
end
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
module BarkingIguana
|
|
2
2
|
module Compound
|
|
3
3
|
class Test
|
|
4
|
+
extend Forwardable
|
|
5
|
+
|
|
4
6
|
attr_accessor :suite
|
|
5
7
|
private :suite=
|
|
6
8
|
|
|
@@ -57,8 +59,7 @@ module BarkingIguana
|
|
|
57
59
|
|
|
58
60
|
def host_manager
|
|
59
61
|
@host_manger ||= begin
|
|
60
|
-
|
|
61
|
-
hosts = stages.map(&:hosts).flatten.uniq(&:ip_address).sort
|
|
62
|
+
hosts = stages.map(&:hosts).flatten.uniq.sort
|
|
62
63
|
HostManager.new(hosts, driver_options)
|
|
63
64
|
end
|
|
64
65
|
end
|
|
@@ -97,9 +98,7 @@ module BarkingIguana
|
|
|
97
98
|
test_file_with_fallback 'Vagrantfile.erb'
|
|
98
99
|
end
|
|
99
100
|
|
|
100
|
-
|
|
101
|
-
host_manager.all
|
|
102
|
-
end
|
|
101
|
+
def_delegator :host_manager, :all, :hosts
|
|
103
102
|
end
|
|
104
103
|
end
|
|
105
104
|
end
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
module BarkingIguana
|
|
2
2
|
module Compound
|
|
3
3
|
class TestStage
|
|
4
|
+
extend Forwardable
|
|
5
|
+
|
|
4
6
|
attr_accessor :test, :directory
|
|
5
7
|
|
|
6
8
|
def initialize test, directory
|
|
@@ -88,14 +90,6 @@ module BarkingIguana
|
|
|
88
90
|
end
|
|
89
91
|
end
|
|
90
92
|
|
|
91
|
-
def hosts
|
|
92
|
-
original_inventory.hosts
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
def control_directory
|
|
96
|
-
test.suite.control_directory
|
|
97
|
-
end
|
|
98
|
-
|
|
99
93
|
def ansible_verbosity
|
|
100
94
|
return 2 unless ENV['ANSIBLE_VERBOSITY']
|
|
101
95
|
ENV['ANSIBLE_VERBOSITY'].to_i
|
|
@@ -105,10 +99,6 @@ module BarkingIguana
|
|
|
105
99
|
Ansible.playbook(playbook_path, run_from: control_directory).inventory(generated_inventory).stream_to(logger).verbosity(ansible_verbosity).diff
|
|
106
100
|
end
|
|
107
101
|
|
|
108
|
-
def suite
|
|
109
|
-
test.suite
|
|
110
|
-
end
|
|
111
|
-
|
|
112
102
|
def setup
|
|
113
103
|
desired_hosts = hosts.sort.map(&:name)
|
|
114
104
|
logger.debug { "Desired hosts for #{display_name}: #{desired_hosts.join(', ')}" }
|
|
@@ -122,10 +112,6 @@ module BarkingIguana
|
|
|
122
112
|
host_manager.shutdown *hosts_to_stop
|
|
123
113
|
end
|
|
124
114
|
|
|
125
|
-
def host_manager
|
|
126
|
-
test.host_manager
|
|
127
|
-
end
|
|
128
|
-
|
|
129
115
|
def converge
|
|
130
116
|
unless File.exists? playbook_path
|
|
131
117
|
logger.debug { "Not running anything because #{playbook_path.inspect} does not exist" }
|
|
@@ -134,16 +120,18 @@ module BarkingIguana
|
|
|
134
120
|
playbook.run
|
|
135
121
|
ensure
|
|
136
122
|
logger.debug { "Removing generated inventory from #{generated_inventory}" }
|
|
137
|
-
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
def verify
|
|
141
|
-
server_spec.run
|
|
123
|
+
FileUtils.rm_r generated_inventory
|
|
142
124
|
end
|
|
143
125
|
|
|
144
126
|
def server_spec
|
|
145
127
|
@server_spec ||= ServerSpec.new(self)
|
|
146
128
|
end
|
|
129
|
+
|
|
130
|
+
def_delegator :original_inventory, :hosts
|
|
131
|
+
def_delegator :test, :suite
|
|
132
|
+
def_delegator :test, :host_manager
|
|
133
|
+
def_delegator :suite, :control_directory
|
|
134
|
+
def_delegator :server_spec, :run, :verify
|
|
147
135
|
end
|
|
148
136
|
end
|
|
149
137
|
end
|
|
@@ -1,111 +1,114 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
module BarkingIguana
|
|
2
|
+
module Compound
|
|
3
|
+
class Vagrant
|
|
4
|
+
extend Forwardable
|
|
5
|
+
attr_accessor :manager
|
|
6
|
+
private :manager=, :manager
|
|
7
|
+
|
|
8
|
+
attr_accessor :vagrant_file_template_path
|
|
9
|
+
private :vagrant_file_template_path=, :vagrant_file_template_path
|
|
10
|
+
|
|
11
|
+
attr_accessor :root
|
|
12
|
+
private :root=, :root
|
|
13
|
+
|
|
14
|
+
attr_accessor :environment
|
|
15
|
+
private :environment=, :environment
|
|
16
|
+
|
|
17
|
+
def initialize manager, options = {}
|
|
18
|
+
self.manager = manager
|
|
19
|
+
self.vagrant_file_template_path = options[:vagrant_file_template_path] || File.expand_path('../../../../resources/Vagrantfile.erb', __FILE__)
|
|
20
|
+
self.root = options[:root] || Dir.pwd
|
|
21
|
+
self.environment = options[:environment] || {}
|
|
22
|
+
end
|
|
20
23
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
24
|
+
include BarkingIguana::Logging::Helper
|
|
25
|
+
include BarkingIguana::Benchmark
|
|
26
|
+
|
|
27
|
+
{
|
|
28
|
+
up: "",
|
|
29
|
+
status: "",
|
|
30
|
+
halt: "-f",
|
|
31
|
+
destroy: "-f"
|
|
32
|
+
}.each_pair do |command, always_args|
|
|
33
|
+
define_method command do |*passed_args|
|
|
34
|
+
logger.debug { "COMMAND: #{command.inspect}, PASSED_ARGS: #{passed_args.inspect}, ALWAYS_ARGS: #{always_args.inspect}" }
|
|
35
|
+
merged_args = ([always_args] + passed_args).flatten.join(' ').strip
|
|
36
|
+
logger.debug { "MERGED ARGS: #{merged_args.inspect}" }
|
|
37
|
+
command_line = "/usr/local/bin/vagrant #{command} #{merged_args}".strip
|
|
38
|
+
logger.debug { "COMMAND LINE: #{command_line.inspect}" }
|
|
39
|
+
logger.debug { "COMMAND ENV: #{environment.inspect}" }
|
|
40
|
+
c = Mixlib::ShellOut.new command_line, cwd: root, env: environment.to_h, live_stream: logger
|
|
41
|
+
benchmark "running command #{command_line.inspect} in #{root.inspect} with env #{environment.to_h.inspect}" do
|
|
42
|
+
c.run_command
|
|
43
|
+
end
|
|
44
|
+
c.error!
|
|
45
|
+
c.stdout
|
|
46
|
+
end
|
|
40
47
|
end
|
|
41
|
-
c.error!
|
|
42
|
-
c.stdout
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
48
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
def write_vagrant_file
|
|
50
|
+
logger.debug { "Writing Vagrantfile to #{vagrant_file_path}" }
|
|
51
|
+
File.open vagrant_file_path, 'w' do |f|
|
|
52
|
+
f.puts vagrant_file_content
|
|
53
|
+
end
|
|
54
|
+
end
|
|
52
55
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
def assign_ip_addresses
|
|
57
|
+
hosts.each do |h|
|
|
58
|
+
next if valid_ip_address? h.ip_address
|
|
59
|
+
ip_address = next_available_ip_address
|
|
60
|
+
logger.debug { "Assigning #{h.name} an IP address: #{ip_address}" }
|
|
61
|
+
h.assign_ip_address ip_address
|
|
62
|
+
end
|
|
63
|
+
end
|
|
61
64
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
def prepare
|
|
66
|
+
assign_ip_addresses
|
|
67
|
+
write_vagrant_file
|
|
68
|
+
end
|
|
66
69
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
def vagrant_file_content
|
|
71
|
+
ERB.new(vagrant_file_template).result binding
|
|
72
|
+
end
|
|
70
73
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
+
def vagrant_file_template
|
|
75
|
+
File.read vagrant_file_template_path
|
|
76
|
+
end
|
|
74
77
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
+
def vagrant_file_path
|
|
79
|
+
File.join root, 'Vagrantfile'
|
|
80
|
+
end
|
|
78
81
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
def refresh_status
|
|
83
|
+
current_status = status.split(/\n/)
|
|
84
|
+
hosts.each do |host|
|
|
85
|
+
current_status.each do |line|
|
|
86
|
+
if line =~ /^#{host.name}\b/
|
|
87
|
+
host.state = line.sub(host.name, '').sub('(virtualbox)', '').strip
|
|
88
|
+
end
|
|
89
|
+
end
|
|
85
90
|
end
|
|
86
91
|
end
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
92
|
|
|
90
|
-
|
|
93
|
+
private
|
|
91
94
|
|
|
92
|
-
|
|
93
|
-
manager.hosts
|
|
94
|
-
end
|
|
95
|
+
def_delegator :manager, :hosts
|
|
95
96
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
def next_available_ip_address
|
|
98
|
+
unassigned_ip_addresses.shift
|
|
99
|
+
end
|
|
99
100
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
def valid_ip_address? ip_address
|
|
102
|
+
ip_address =~ /^10\.8\./
|
|
103
|
+
end
|
|
103
104
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
105
|
+
def unassigned_ip_addresses
|
|
106
|
+
@unassigned_ip_addresses ||= begin
|
|
107
|
+
assignable_ip_addresses = (10..200).to_a.map { |dd| "10.8.42.#{dd}" }
|
|
108
|
+
assigned_ip_addresses = hosts.map(&:ip_address)
|
|
109
|
+
assignable_ip_addresses - assigned_ip_addresses
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
110
113
|
end
|
|
111
114
|
end
|
data/resources/Vagrantfile.erb
CHANGED
|
@@ -8,7 +8,7 @@ Vagrant.configure(2) do |config|
|
|
|
8
8
|
<% hosts.each do |host| %>
|
|
9
9
|
config.vm.define "<%= host.name %>" do |this|
|
|
10
10
|
this.vm.hostname = "<%= host.name %>"
|
|
11
|
-
this.vm.network "private_network", ip: "<%= host.
|
|
11
|
+
this.vm.network "private_network", ip: "<%= host.ip_address %>"
|
|
12
12
|
end
|
|
13
13
|
<% end %>
|
|
14
14
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: barking_iguana-compound
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Craig R Webster
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-01-
|
|
11
|
+
date: 2017-01-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -184,6 +184,13 @@ files:
|
|
|
184
184
|
- docs/TODO.md
|
|
185
185
|
- docs/_config.yml
|
|
186
186
|
- docs/index.md
|
|
187
|
+
- examples/simple/Gemfile
|
|
188
|
+
- examples/simple/Gemfile.lock
|
|
189
|
+
- examples/simple/Rakefile
|
|
190
|
+
- examples/simple/test/compound/simple/000-setup/example-host/example_spec.rb
|
|
191
|
+
- examples/simple/test/compound/simple/000-setup/playbook.yml
|
|
192
|
+
- examples/simple/test/compound/simple/Vagrantfile
|
|
193
|
+
- examples/simple/test/compound/simple/inventory
|
|
187
194
|
- exe/compound
|
|
188
195
|
- lib/barking_iguana/compound.rb
|
|
189
196
|
- lib/barking_iguana/compound/ansible.rb
|
|
@@ -203,6 +210,7 @@ files:
|
|
|
203
210
|
- lib/barking_iguana/compound/vagrant.rb
|
|
204
211
|
- lib/barking_iguana/compound/version.rb
|
|
205
212
|
- resources/Vagrantfile.erb
|
|
213
|
+
- resources/spec_helper.rb
|
|
206
214
|
homepage: https://github.com/barkingiguana/compound
|
|
207
215
|
licenses: []
|
|
208
216
|
metadata:
|
|
@@ -223,7 +231,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
223
231
|
version: '0'
|
|
224
232
|
requirements: []
|
|
225
233
|
rubyforge_project:
|
|
226
|
-
rubygems_version: 2.5.
|
|
234
|
+
rubygems_version: 2.4.5.1
|
|
227
235
|
signing_key:
|
|
228
236
|
specification_version: 4
|
|
229
237
|
summary: Compound testing of Ansible playbooks
|