kitchen-lxd_cli 0.1.2 → 0.1.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/.kitchen/logs/kitchen.log +26 -29
- data/README.md +60 -6
- data/lib/kitchen/driver/lxd_cli.rb +58 -7
- data/lib/kitchen/driver/lxd_cli_version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a65b448e80451e4143b9f1ef2eaf7bb0f5dab4f
|
4
|
+
data.tar.gz: 7fffe1a9ddd489f45fcbe28b8dbf4a6afa49e9e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8817e841aa26dafd5e7c4bf4381875c10f9983a348d5a703a141cd62a98dcc41a9705f96fa37320065c0e9bf5def81f0bc7fff07fcb4337dcc993bf09f65e2c
|
7
|
+
data.tar.gz: 76f04d46e7e53b667e9d846e1c27f5d86af5df6e83ef023f4a99adb6b2228a92f29caaf826607f6e63185a35051e329f127df0219bd7ef073d3d462b567032b7
|
data/.kitchen/logs/kitchen.log
CHANGED
@@ -1,29 +1,26 @@
|
|
1
|
-
|
2
|
-
E, [2015-11-
|
3
|
-
E, [2015-11-
|
4
|
-
E, [2015-11-
|
5
|
-
E, [2015-11-
|
6
|
-
E, [2015-11-
|
7
|
-
E, [2015-11-
|
8
|
-
E, [2015-11-
|
9
|
-
E, [2015-11-
|
10
|
-
E, [2015-11-
|
11
|
-
E, [2015-11-
|
12
|
-
E, [2015-11-
|
13
|
-
E, [2015-11-
|
14
|
-
E, [2015-11-
|
15
|
-
E, [2015-11-
|
16
|
-
E, [2015-11-
|
17
|
-
E, [2015-11-
|
18
|
-
E, [2015-11-
|
19
|
-
E, [2015-11-
|
20
|
-
E, [2015-11-
|
21
|
-
E, [2015-11-
|
22
|
-
E, [2015-11-
|
23
|
-
E, [2015-11-
|
24
|
-
E, [2015-11-
|
25
|
-
E, [2015-11-
|
26
|
-
E, [2015-11-
|
27
|
-
E, [2015-11-01T00:01:20.463485 #7769] ERROR -- Kitchen: /opt/chefdk/bin/kitchen:14:in `load'
|
28
|
-
E, [2015-11-01T00:01:20.463523 #7769] ERROR -- Kitchen: /opt/chefdk/bin/kitchen:14:in `<main>'
|
29
|
-
E, [2015-11-01T00:01:20.463543 #7769] ERROR -- Kitchen: ----------------------
|
1
|
+
E, [2015-11-06T17:54:18.362107 #26784] ERROR -- Kitchen: ------Exception-------
|
2
|
+
E, [2015-11-06T17:54:18.362275 #26784] ERROR -- Kitchen: Class: Kitchen::UserError
|
3
|
+
E, [2015-11-06T17:54:18.362315 #26784] ERROR -- Kitchen: Message: Kitchen YAML file /home/braden/kitchen-lxd_cli/.kitchen.yml does not exist.
|
4
|
+
E, [2015-11-06T17:54:18.362337 #26784] ERROR -- Kitchen: ------Backtrace-------
|
5
|
+
E, [2015-11-06T17:54:18.362355 #26784] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/loader/yaml.rb:74:in `read'
|
6
|
+
E, [2015-11-06T17:54:18.362373 #26784] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/config.rb:145:in `data'
|
7
|
+
E, [2015-11-06T17:54:18.362391 #26784] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/config.rb:124:in `suites'
|
8
|
+
E, [2015-11-06T17:54:18.362408 #26784] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/config.rb:175:in `filter_instances'
|
9
|
+
E, [2015-11-06T17:54:18.362426 #26784] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/config.rb:134:in `build_instances'
|
10
|
+
E, [2015-11-06T17:54:18.362443 #26784] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/config.rb:110:in `instances'
|
11
|
+
E, [2015-11-06T17:54:18.362461 #26784] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/command.rb:115:in `filtered_instances'
|
12
|
+
E, [2015-11-06T17:54:18.362478 #26784] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/command.rb:145:in `parse_subcommand'
|
13
|
+
E, [2015-11-06T17:54:18.362495 #26784] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/command/list.rb:32:in `call'
|
14
|
+
E, [2015-11-06T17:54:18.362512 #26784] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/cli.rb:56:in `perform'
|
15
|
+
E, [2015-11-06T17:54:18.362552 #26784] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/cli.rb:108:in `list'
|
16
|
+
E, [2015-11-06T17:54:18.362570 #26784] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
|
17
|
+
E, [2015-11-06T17:54:18.362587 #26784] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
|
18
|
+
E, [2015-11-06T17:54:18.362604 #26784] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/cli.rb:308:in `invoke_task'
|
19
|
+
E, [2015-11-06T17:54:18.362621 #26784] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
|
20
|
+
E, [2015-11-06T17:54:18.362638 #26784] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
|
21
|
+
E, [2015-11-06T17:54:18.362655 #26784] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/bin/kitchen:13:in `block in <top (required)>'
|
22
|
+
E, [2015-11-06T17:54:18.362672 #26784] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/errors.rb:154:in `with_friendly_errors'
|
23
|
+
E, [2015-11-06T17:54:18.362689 #26784] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/bin/kitchen:13:in `<top (required)>'
|
24
|
+
E, [2015-11-06T17:54:18.362706 #26784] ERROR -- Kitchen: /opt/chefdk/bin/kitchen:14:in `load'
|
25
|
+
E, [2015-11-06T17:54:18.362723 #26784] ERROR -- Kitchen: /opt/chefdk/bin/kitchen:14:in `<main>'
|
26
|
+
E, [2015-11-06T17:54:18.362739 #26784] ERROR -- Kitchen: ----------------------
|
data/README.md
CHANGED
@@ -42,7 +42,21 @@ driver:
|
|
42
42
|
image_os: ubuntu
|
43
43
|
image_release: trusty
|
44
44
|
profile: my_lxc_profile
|
45
|
-
config:
|
45
|
+
config:
|
46
|
+
limits.memory: 2G
|
47
|
+
limits.cpus: 2
|
48
|
+
boot.autostart: true
|
49
|
+
domain_name: lxc
|
50
|
+
ip_gateway: 10.0.3.1
|
51
|
+
dns_servers: ["10.0.3.1", "8.8.8.8", "8.8.4.4"]
|
52
|
+
# never_destroy: true
|
53
|
+
lxd_proxy_install: true
|
54
|
+
# lxd_proxy_destroy: true
|
55
|
+
# lxd_proxy_verify: true
|
56
|
+
# lxd_proxy_update: true
|
57
|
+
# lxd_proxy_path: "~/.lxd_proxy"
|
58
|
+
# lxd_proxy_github_url: "-b development --single-branch https://github.com/bradenwright/cookbook-lxd_polipo
|
59
|
+
|
46
60
|
domain_name: localdomain
|
47
61
|
dns_servers: ["8.8.8.8","8.8.4.4"]
|
48
62
|
ipv4: 10.0.3.99/24
|
@@ -113,7 +127,13 @@ Current config options:
|
|
113
127
|
* dns_servers
|
114
128
|
* ipv4
|
115
129
|
* ip_gateway
|
116
|
-
*
|
130
|
+
* never_destroy
|
131
|
+
* lxd_proxy_install
|
132
|
+
* lxd_proxy_destroy
|
133
|
+
* lxd_proxy_verify
|
134
|
+
* lxd_proxy_update
|
135
|
+
* lxd_proxy_path
|
136
|
+
* lxd_proxy_github_url
|
117
137
|
|
118
138
|
public_key_path:
|
119
139
|
|
@@ -144,7 +164,7 @@ Default is Nil. See LXC documentation but a lxc profile can be specified. Whic
|
|
144
164
|
|
145
165
|
config:
|
146
166
|
|
147
|
-
Default is Nil. See LXC documentation but a lxc config container key/value can be specified. [LXC Container Config Options](https://github.com/lxc/lxd/blob/master/specs/configuration.md#keyvalue-configuration-1).
|
167
|
+
Default is Nil. See LXC documentation but a lxc config container key/value can be specified. [LXC Container Config Options](https://github.com/lxc/lxd/blob/master/specs/configuration.md#keyvalue-configuration-1). Hash of config options is looped over and "lxc config set" command is run for each key/value pair.
|
148
168
|
|
149
169
|
domain_name:
|
150
170
|
|
@@ -165,10 +185,42 @@ ip_gateway:
|
|
165
185
|
Allows for a default gateway to be set. If ipv4 is used ip_gateway default value is 10.0.3.1, if dhcp is used then default gateway is given via dhcp. Default gateway is also used as a dns_server if static ips are used and no dns server is specified.
|
166
186
|
|
167
187
|
|
168
|
-
|
188
|
+
never_destroy:
|
169
189
|
|
170
190
|
Default is false. Can be useful sometimes to keep machines intact. It allows kitchen destroy to stop container, kitchen create can be issued to start boxes if they are not running.
|
171
191
|
|
192
|
+
lxd_proxy_install:
|
193
|
+
|
194
|
+
Default is false. If true it installs polipo proxy by cloning into .lxd_proxy and running test kitchen in that directory. It only runs the first time unless you tell it to update. Also if the proxy already exists from another project, the existing container (named proxy-ubuntu-1404) will be used, started if necessary. Recommended use for testing would be to set this value to true and leave all others as defaults. It will significantly increase your test kitchen runs. But be sure to setup nodes in .kitchen.yml with normal proxy settings, e.g.
|
195
|
+
|
196
|
+
```
|
197
|
+
provisioner:
|
198
|
+
name: chef_zero
|
199
|
+
http_proxy: http://10.0.3.5:8123
|
200
|
+
https_proxy: https://10.0.3.5:8123
|
201
|
+
chef_omnibus_url: http://www.chef.io/chef/install.sh
|
202
|
+
```
|
203
|
+
|
204
|
+
lxd_proxy_destroy:
|
205
|
+
|
206
|
+
Default is false. By default proxy is not destroyed and it is set to auto boot. This way after proxy is installed once, it should just be there and usable for all your cookbooks.
|
207
|
+
|
208
|
+
lxd_proxy_verify:
|
209
|
+
|
210
|
+
Default is false. If false then kitchen converge command is used, which speeds up the process. If you want to run serverspec tests to ensure polipo is up set this value to true.
|
211
|
+
|
212
|
+
lxd_proxy_update:
|
213
|
+
|
214
|
+
Default is false. Very little has been tested, and could be errors that one would manually have to deal with. But it attempts to pull from git, update berkshelf, re-run kitchen converge. Takes extra time but may come in useful. At this point I would recommend just destroying and recreating the lxd_proxy if there are any issues.
|
215
|
+
|
216
|
+
lxd_proxy_path:
|
217
|
+
|
218
|
+
Default is `~/.lxd_proxy` Path of where github gets cloned can be changed. That location is used so only 1 copy needs to exist on disk for all cookbook. But most of the disk space is the lxc container thats running the polipo proxy, container is named proxy-ubuntu-1404 by default.
|
219
|
+
|
220
|
+
lxd_proxy_github_url:
|
221
|
+
|
222
|
+
Default is https://github.com/bradenwright/cookbook-lxd_polipo basically if can be overridden so that whatever repo is used. Idea being that someone can customize the polipo install I have setup. Or try to use a completely different type of proxy (not polipo) as long as the git-repo would create a proxy by running `bundle install` and `bundle exec kitchen converge`. Also if you don't want to use github if you setup a container named proxy-ubuntu-1404, ie `lxc info proxy-ubuntu-1404` returns a box it will be used.
|
223
|
+
|
172
224
|
### <a name="config-require-chef-omnibus"></a> require\_chef\_omnibus
|
173
225
|
|
174
226
|
Determines whether or not a Chef [Omnibus package][chef_omnibus_dl] will be
|
@@ -191,9 +243,11 @@ The default value is unset, or `nil`.
|
|
191
243
|
* Config option to add remote for lxc, so images can be downloaded from other locations. Currently would have to manually be done in LXD/LXC
|
192
244
|
* Config option to publish container on verify
|
193
245
|
* Config option to install upstart (not used by default in containers)
|
194
|
-
* Config option for proxy/cache
|
195
|
-
* Ability to set more than 1 config (key/value)
|
196
246
|
* Example chef cookbook which uses this driver to setup a multi-node web application
|
247
|
+
* Allow specifying name of container
|
248
|
+
* More thorough check to see if proxy exists, right now looking for directory
|
249
|
+
* Ability to configure ip, maybe ram, etc too, for lxd_proxy_install (currently would need to be done manually, either via lxc or via .lxd_proxy/.kitchen.yml)
|
250
|
+
* Write a transport for lxd_cli, using ssh is a lot slower than using lxc commands
|
197
251
|
|
198
252
|
## <a name="development"></a> Development
|
199
253
|
|
@@ -8,7 +8,7 @@
|
|
8
8
|
# you may not use this file except in compliance with the License.
|
9
9
|
# You may obtain a copy of the License at
|
10
10
|
#
|
11
|
-
# http://
|
11
|
+
# http://wwoow.apache.org/licenses/LICENSE-2.0
|
12
12
|
#
|
13
13
|
# Unless required by applicable law or agreed to in writing, software
|
14
14
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
@@ -36,17 +36,20 @@ module Kitchen
|
|
36
36
|
File.expand_path('~/.ssh/id_ecdsa.pub')
|
37
37
|
].find { |path| File.exist?(path) }
|
38
38
|
end
|
39
|
-
default_config :
|
39
|
+
default_config :never_destroy, false
|
40
|
+
default_config :lxd_proxy_path, "#{ENV['HOME']}/.lxd_proxy"
|
41
|
+
default_config :lxd_proxy_update, false
|
40
42
|
|
41
43
|
required_config :public_key_path
|
42
44
|
|
43
45
|
def create(state)
|
46
|
+
install_proxy if config[:lxd_proxy_install] && config[:lxd_proxy_install] == true
|
47
|
+
|
44
48
|
unless exists?
|
45
49
|
image_name = create_image_if_missing
|
46
50
|
profile = "-p #{config[:profile]}" if config[:profile]
|
47
|
-
lxc_config = "-c #{config[:config]}" if config[:config]
|
48
51
|
info("Initializing container #{instance.name}")
|
49
|
-
run_lxc_command("init #{image_name} #{instance.name} #{profile}
|
52
|
+
run_lxc_command("init #{image_name} #{instance.name} #{profile}")
|
50
53
|
end
|
51
54
|
|
52
55
|
config_and_start_container unless running?
|
@@ -62,10 +65,13 @@ module Kitchen
|
|
62
65
|
info("Stopping container #{instance.name}")
|
63
66
|
run_lxc_command("stop #{instance.name}")
|
64
67
|
end
|
65
|
-
|
66
|
-
|
68
|
+
unless config[:never_destroy]
|
69
|
+
info("Deleting container #{instance.name}")
|
70
|
+
run_lxc_command("delete #{instance.name}") unless config[:never_destroy] && config[:never_destroy] == true
|
71
|
+
end
|
67
72
|
end
|
68
73
|
state.delete(:hostname)
|
74
|
+
destroy_proxy if config[:lxd_proxy_destroy] && config[:lxd_proxy_destroy] == true
|
69
75
|
end
|
70
76
|
|
71
77
|
private
|
@@ -141,6 +147,11 @@ module Kitchen
|
|
141
147
|
arg_disable_dhcp = "&& lxc exec #{instance.name} -- sed -i 's/dhcp/manual/g' /etc/network/interfaces.d/eth0.cfg"
|
142
148
|
end
|
143
149
|
# TODO: loop over/run all lxc config settings passed in or figure out how to use multiple with lxc init
|
150
|
+
IO.popen("bash", "r+") do |p|
|
151
|
+
config[:config].each do |key, value|
|
152
|
+
p.puts("lxc config set #{instance.name} #{key} #{value}")
|
153
|
+
end if config[:config]
|
154
|
+
end
|
144
155
|
info("Starting container #{instance.name}")
|
145
156
|
run_lxc_command("start #{instance.name} #{arg_disable_dhcp}")
|
146
157
|
end
|
@@ -233,6 +244,46 @@ module Kitchen
|
|
233
244
|
debug("Finished Copying public key from #{config[:public_key_path]} to #{instance.name}")
|
234
245
|
end
|
235
246
|
|
247
|
+
def install_proxy
|
248
|
+
IO.popen("bash", "w") do |p|
|
249
|
+
if config[:lxd_proxy_verify] == true
|
250
|
+
kitchen_command = "kitchen verify"
|
251
|
+
else
|
252
|
+
kitchen_command = "kitchen converge"
|
253
|
+
end
|
254
|
+
|
255
|
+
#TODO: more thorough check to see if proxy is running. Check via lxc commands
|
256
|
+
if config[:lxd_proxy_update] == true && File.exists?(config[:lxd_proxy_path])
|
257
|
+
debug("Updating proxy, if it fails you may either not want to update or recreate proxy-ubuntu-1404")
|
258
|
+
p.puts("cd #{config[:lxd_proxy_path]}")
|
259
|
+
p.puts("git pull")
|
260
|
+
p.puts("bundle update")
|
261
|
+
p.puts("berks update")
|
262
|
+
p.puts("bundle exec #{kitchen_command}")
|
263
|
+
elsif !File.exists?(config[:lxd_proxy_path])
|
264
|
+
github_url = config[:lxd_proxy_github_url] || "https://github.com/bradenwright/cookbook-lxd_polipo"
|
265
|
+
p.puts("git clone #{github_url} #{config[:lxd_proxy_path]}")
|
266
|
+
p.puts("cd #{config[:lxd_proxy_path]}")
|
267
|
+
p.puts("bundle install")
|
268
|
+
p.puts("bundle exec #{kitchen_command}")
|
269
|
+
end
|
270
|
+
#TODO: if Rakefile found run rake install instead
|
271
|
+
# This would allow others to build out different options
|
272
|
+
# for more complicated proxy installs
|
273
|
+
end rescue nil
|
274
|
+
end
|
275
|
+
|
276
|
+
def destroy_proxy
|
277
|
+
IO.popen("bash", "w") do |p|
|
278
|
+
if File.exists?(config[:lxd_proxy_path])
|
279
|
+
p.puts("cd #{config[:lxd_proxy_path]}")
|
280
|
+
p.puts("bundle exec kitchen destroy")
|
281
|
+
p.puts("cd ..")
|
282
|
+
p.puts("rm -rf #{config[:lxd_proxy_path]}")
|
283
|
+
end
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
236
287
|
def wait_for_ip_address
|
237
288
|
info("Waiting for network to become ready")
|
238
289
|
begin
|
@@ -249,7 +300,7 @@ module Kitchen
|
|
249
300
|
def wait_for_path(path)
|
250
301
|
begin
|
251
302
|
debug("Waiting for #{path} to become available...")
|
252
|
-
run_lxc_command("exec #{instance.name} -- ls #{path}")
|
303
|
+
run_lxc_command("exec #{instance.name} -- ls #{path} > /dev/null 2>&1")
|
253
304
|
break if $?.to_i == 0
|
254
305
|
sleep 0.3
|
255
306
|
end while true
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitchen-lxd_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Braden Wright
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-kitchen
|