kitchen-lxd_sling 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +85 -23
- data/lib/kitchen/driver/lxd.rb +12 -10
- data/lib/kitchen/driver/lxd_version.rb +1 -1
- data/lib/kitchen/transport/lxd.rb +5 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7556790d91c1247582f98d881977477f69bf3722f2309f5ad4f5ebc0d63d771
|
4
|
+
data.tar.gz: 55106364c0752164bd48376d83a9baf4f02bbfea0fb3af3a415daab21650f528
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cff8a63f51e3c7225a58514bfe45242035892ced3e4d00775f5ee133596ef3f7ba0f53453df95611c384955e8feebde76853b002270f21732bbdc34c102eafc4
|
7
|
+
data.tar.gz: 147604fd1caec7c1499c71feff72f5c88150e3576d73eb1ca4645544230d0d3b3b0ec826fb53becf32dba30f0e60a7799a58eae9837ab39b723f836623bfed24
|
data/README.md
CHANGED
@@ -1,39 +1,101 @@
|
|
1
|
-
#
|
1
|
+
# kitchen-lxd_sling [![Build Status](https://travis-ci.org/NexusSW/kitchen-lxd_sling.svg?branch=master)](https://travis-ci.org/NexusSW/kitchen-lxd_sling) [![Dependency Status](https://gemnasium.com/badges/github.com/NexusSW/kitchen-lxd_sling.svg)](https://gemnasium.com/github.com/NexusSW/kitchen-lxd_sling)
|
2
2
|
|
3
|
-
|
3
|
+
Test Kitchen driver for LXD. This gem provides a driver, and a transport allowing native access to your containers running under LXD.
|
4
4
|
|
5
|
-
|
5
|
+
## Requirements
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
* [test-kitchen](https://github.com/test-kitchen/test-kitchen/)
|
8
|
+
* LXD host running version >= 2.0
|
9
|
+
* Authority to access your LXD host:
|
10
|
+
* be a member of the lxd group if accessing LXD locally
|
11
|
+
* or have an already trusted client cert if accessing remotely
|
10
12
|
|
11
|
-
|
12
|
-
gem 'kitchen-lxd_sling'
|
13
|
-
```
|
13
|
+
## Installation
|
14
14
|
|
15
|
-
|
15
|
+
$ gem install kitchen-lxd_sling
|
16
16
|
|
17
|
-
|
17
|
+
And if you're testing with inspec, you'll also need to install our Train transport: (Requires `kitchen-inspec ~> 0.22`)
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
$ gem install kitchen-lxd_sling
|
19
|
+
$ gem install train-lxd
|
22
20
|
|
23
21
|
## Usage
|
24
22
|
|
25
|
-
|
26
|
-
|
27
|
-
## Development
|
23
|
+
Basic kitchen.yml entries with a local LXD host:
|
28
24
|
|
29
|
-
|
25
|
+
```yaml
|
26
|
+
driver: lxd
|
27
|
+
transport: lxd
|
28
|
+
...
|
29
|
+
```
|
30
30
|
|
31
|
-
|
31
|
+
And if your host is remote to where you're running kitchen, then this is 'likely' all that you will need:
|
32
32
|
|
33
|
-
|
33
|
+
```yaml
|
34
|
+
driver:
|
35
|
+
name: lxd
|
36
|
+
server: <hostname>
|
37
|
+
rest_options:
|
38
|
+
verify_ssl: false
|
34
39
|
|
35
|
-
|
40
|
+
transport: lxd
|
41
|
+
...
|
42
|
+
```
|
36
43
|
|
37
|
-
|
44
|
+
### Available options
|
45
|
+
|
46
|
+
```yaml
|
47
|
+
driver:
|
48
|
+
name: lxd
|
49
|
+
server: <hostname>
|
50
|
+
port: 8443
|
51
|
+
username: ubuntu
|
52
|
+
image_server:
|
53
|
+
server: https://images.linuxcontainers.org
|
54
|
+
protocol: simplestreams
|
55
|
+
alias: ubuntu/xenial
|
56
|
+
fingerprint: ce8d746a8567
|
57
|
+
properties:
|
58
|
+
architecture: amd64
|
59
|
+
os: Ubuntu
|
60
|
+
release: xenial
|
61
|
+
profiles:
|
62
|
+
- default
|
63
|
+
- kitchen
|
64
|
+
...
|
65
|
+
config:
|
66
|
+
security.privileged: true
|
67
|
+
security.nesting: true
|
68
|
+
linux.kernel_modules: ip_tables,ip6_tables
|
69
|
+
...
|
70
|
+
ssh_login:
|
71
|
+
username: ubuntu
|
72
|
+
public_key: <local path to file: ~/.ssh/id_rsa.pub>
|
73
|
+
rest_options:
|
74
|
+
verify_ssl: false
|
75
|
+
ssl:
|
76
|
+
verify: false
|
77
|
+
client_cert: <local path to file: ~/.config/lxc/client.crt>
|
78
|
+
client_key: <local path to file: ~/.config/lxc/client.key>
|
79
|
+
...
|
80
|
+
```
|
38
81
|
|
39
|
-
|
82
|
+
#### Options (explained)
|
83
|
+
|
84
|
+
option | default | description
|
85
|
+
|---|:---:|---|
|
86
|
+
server | | Hostname of a remote LXD server. If left unspecified, then local CLI commands will be issued via `lxc`.
|
87
|
+
port | 8443 | Port on **server** where LXD is listening. Ignored unless **server** is specified.
|
88
|
+
username | root | If the base image has additional user accounts built-in, then change this value to run all commands as a different user. **Warning**: _passwordless sudo may be required by the remainder of the test suite_
|
89
|
+
image_server.server | https://images.linuxcontainers.org | Default source for base container images
|
90
|
+
image_server.protocol | _\<calculated>_ | `simplestreams` or `lxd` protocol with which to communicate with the **image_server**
|
91
|
+
alias | _\<calculated>_ | Name of the image on the **image_server**. Derived from platform name in kitchen.yml's `platforms:` section unless specified here, and unless **fingerprint** or **properties** are specified.
|
92
|
+
fingerprint | | Fingerprint of a specific image on the **image_server**
|
93
|
+
properties | | Search parameters for finding an image on the **image_server**
|
94
|
+
profiles | default | Profiles on the LXD host to apply to any newly created containers
|
95
|
+
config | | Additional container properties passed verbatim to the LXD Host. Refer to LXD's documentation for valid values https://github.com/lxc/lxd/blob/master/doc/containers.md
|
96
|
+
ssh_login.username | | If the base image has sshd enabled and running, specify the username here and the driver will set up the container for ssh access. Overrides the base **username**
|
97
|
+
ssh_login.public_key | ~/.ssh/id_rsa.pub | Public key to use for authenticating ssh connections.
|
98
|
+
rest_options.verify_ssl | true | _Convenience option_ When connecting to a remote LXD host, should the hosts SSL certificate be verified
|
99
|
+
rest_options.ssl.verify | true | Overrides **rest_options.verify_ssl**.
|
100
|
+
rest_options.ssl.client_cert | ~/.config/lxc/client.crt | Client certificate authenticating access to the LXD host.
|
101
|
+
rest_options.ssl.client_key | ~/.config/lxc/client.key | Private key for the client certificate.
|
data/lib/kitchen/driver/lxd.rb
CHANGED
@@ -54,29 +54,31 @@ module Kitchen
|
|
54
54
|
# Which also means that you might need to do 'ssh_login: false' in the config if you're using a cloud-image and aren't routable
|
55
55
|
# think ahead for default behaviour once LXD can port forward
|
56
56
|
# FUTURE: If I get time I'll look into faking a port forward with something under /dev/ until then
|
57
|
+
info 'Waiting for an IP address...'
|
58
|
+
state[:ip_address] = state[:hostname] = container_ip(state)
|
57
59
|
if use_ssh?
|
58
60
|
# Normalize [:ssh_login]
|
59
61
|
config[:ssh_login] = { username: config[:ssh_login] } if config[:ssh_login].is_a? String
|
60
|
-
config[:ssh_login]
|
62
|
+
config[:ssh_login] ||= {} # if config[:ssh_login] && !config.to_hash[:ssh_login].is_a?(Hash)
|
61
63
|
|
62
|
-
state[:username] = config[:ssh_login][:username] if config[:ssh_login]
|
64
|
+
state[:username] = config[:ssh_login][:username] if config[:ssh_login].key? :username
|
63
65
|
state[:username] ||= 'root'
|
64
|
-
|
65
|
-
info 'Waiting for an IP address...'
|
66
|
-
state[:ip_address] = state[:hostname] = container_ip(state)
|
67
|
-
setup_ssh(state[:username], "#{ENV['HOME']}/.ssh/id_rsa.pub", state)
|
66
|
+
setup_ssh(state[:username], config[:ssh_login][:public_key] || "#{ENV['HOME']}/.ssh/id_rsa.pub", state)
|
68
67
|
info "SSH access enabled on #{state[:ip_address]}"
|
69
68
|
else
|
70
69
|
# TODO: this section is only for the base images on linuxcontainers.org... (and I still need to account for yum)
|
71
70
|
# they need patched because they don't have wget, or anything else with which to download the chef client
|
72
71
|
# Custom images should account for this, so I won't run this patch for them (in the name of testing speed)
|
73
|
-
info 'Waiting for network access...'
|
74
|
-
state[:ip_address] = container_ip(state) # This is only here to wait until the net is up so we can download packages
|
75
72
|
unless cloud_image?
|
76
|
-
info 'Installing additional dependencies...'
|
77
73
|
transport = nx_transport(state)
|
78
74
|
transport.reset_user
|
79
|
-
|
75
|
+
# only centos/7 and various ubuntu versions have been tested here
|
76
|
+
# - ubuntu non-cloud has no download utilities in order to dl the chef package so we must adapt that
|
77
|
+
# - centos/7 needs sudo installed, or you need to use sudo:false on the provisioner... leaving it explicit for the user to fix
|
78
|
+
unless transport.execute('test -d /etc/apt').error?
|
79
|
+
info 'Installing additional dependencies...'
|
80
|
+
transport.execute('apt-get install openssl curl ca-certificates -y').error!
|
81
|
+
end
|
80
82
|
end
|
81
83
|
end
|
82
84
|
end
|
@@ -49,7 +49,7 @@ module Kitchen
|
|
49
49
|
logger << stdout_chunk if stdout_chunk
|
50
50
|
logger << stderr_chunk if stderr_chunk
|
51
51
|
end
|
52
|
-
res.error
|
52
|
+
raise TransportFailed.new(res.command, res.exitstatus) if res.error?
|
53
53
|
end
|
54
54
|
|
55
55
|
def upload(locals, remote)
|
@@ -61,6 +61,8 @@ module Kitchen
|
|
61
61
|
nx_transport.upload_folder local, remote
|
62
62
|
end
|
63
63
|
end
|
64
|
+
rescue NexusSW::LXD::RestAPI::Error => ex
|
65
|
+
raise TransportFailed, ex
|
64
66
|
end
|
65
67
|
|
66
68
|
def download(remotes, local)
|
@@ -68,6 +70,8 @@ module Kitchen
|
|
68
70
|
[remotes].flatten.each do |remote|
|
69
71
|
nx_transport.download_folder remote.to_s, local, auto_detect: true
|
70
72
|
end
|
73
|
+
rescue NexusSW::LXD::RestAPI::Error => ex
|
74
|
+
raise TransportFailed, ex
|
71
75
|
end
|
72
76
|
|
73
77
|
def login_command
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitchen-lxd_sling
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Zachariasen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lxd-common
|