kitchen-lxd_sling 0.5.2 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f7ba5674d2624b638a7ee3d0b0a4136749891dfa110403e9ce0d0c28768eed6f
4
- data.tar.gz: 01c04cc5eeb4c4ae63606dbe9893dbde9866400c87414b605d6ba08e7a1696b9
3
+ metadata.gz: 3abb096dba2a0096045fbc2f24a8030fb1fa49670c9f9a6b8e916dbe9df1d945
4
+ data.tar.gz: 43142550d61d9bce30bdfa2310f4490728729044e35b88af552b3176e0b72469
5
5
  SHA512:
6
- metadata.gz: fcfa99f2bf06b113b1975cd537e0cfe2935807ba59494c292f5262d799e0be3e6b14d207f1df5055ec012000ffa87e1773e45f9b2fbb01a0370367583ab5dd2d
7
- data.tar.gz: 25698c18402960deba7819ef69230250de8ad05ab0682d93511b53610445cf75f07ca86c6ca528ffd717d1e6bae77dc9dfcfe87db30a07c3085cdd2b417fbd24
6
+ metadata.gz: 1e30da85043672b192e5c5d5c2f948f130cb4a18db835d906b6331ba81e7ba8d6fa57bf3666a5a650db6242ec030d260a87d9904ffeb6d796c2794bf87455015
7
+ data.tar.gz: 2c760c7997d10b71ec7cdf548bef93c05516cce6310dff8024ce682c8d8eb5b33abe06f788fa379f7f4e91c8201cd3e326900df18e9eeff3ab5ff78c4f2a5615
@@ -0,0 +1,3 @@
1
+ # Managing line ending conversions
2
+ # See http://git-scm.com/docs/gitattributes#_end-of-line_conversion
3
+ * text=auto
@@ -6,17 +6,15 @@ provisioner:
6
6
  name: chef_zero
7
7
 
8
8
  platforms:
9
- - name: ubuntu-16.04
10
- verifier: inspec
9
+ - name: ubuntu-18.04
11
10
 
12
- transport: lxd
13
-
14
11
  suites:
15
12
  - name: kitchen-lxd-native
13
+ verifier: inspec
16
14
  provisioner:
17
15
  downloads:
18
16
  '/tmp/kitchen': <%= Dir.tmpdir %>/kitchen-download-test
19
17
  - name: kitchen-lxd-cloud
20
18
  driver:
21
- image_server: https://cloud-images.ubuntu.com/releases
22
- username: ubuntu
19
+ image_server: https://cloud-images.ubuntu.com/daily
20
+ ssh_login: ubuntu
data/Berksfile CHANGED
@@ -1,7 +1,7 @@
1
- source 'https://supermarket.chef.io'
1
+ source "https://supermarket.chef.io"
2
2
 
3
- cookbook 'lxd_sling', git: 'https://github.com/nexussw/lxd_sling.git'
3
+ cookbook "lxd_sling", git: "https://github.com/nexussw/lxd_sling.git"
4
4
 
5
5
  group :test do
6
- cookbook 'test', path: 'test/cookbooks/test'
6
+ cookbook "test", path: "test/cookbooks/test"
7
7
  end
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in kitchen-lxd_sling.gemspec
4
4
  gemspec
data/Rakefile CHANGED
@@ -1,13 +1,13 @@
1
- require 'bundler/gem_tasks'
2
- require 'rspec/core/rake_task'
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
6
  task default: :spec
7
7
 
8
8
  begin
9
- require 'kitchen/rake_tasks'
9
+ require "kitchen/rake_tasks"
10
10
  Kitchen::RakeTasks.new
11
11
  rescue LoadError
12
- puts '>>>>> Kitchen gem not loaded, omitting tasks' unless ENV['CI']
12
+ puts ">>>>> Kitchen gem not loaded, omitting tasks" unless ENV["CI"]
13
13
  end
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'bundler/setup'
4
- require 'kitchen/lxd_sling'
3
+ require "bundler/setup"
4
+ require "kitchen/lxd_sling"
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +10,5 @@ require 'kitchen/lxd_sling'
10
10
  # require 'pry'
11
11
  # Pry.start
12
12
 
13
- require 'irb'
13
+ require "irb"
14
14
  IRB.start(__FILE__)
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'yaml'
3
+ require "yaml"
4
4
 
5
5
  def symbolize_keys(hash)
6
6
  {}.tap do |retval|
@@ -12,12 +12,12 @@ end
12
12
 
13
13
  state = symbolize_keys(YAML.load(File.read(ARGV[0])))
14
14
 
15
- require 'kitchen'
16
- require 'kitchen/driver/lxd/host_locator'
17
- require 'tty/reader'
18
- require 'tty/screen'
19
- require 'io/wait'
20
- require 'io/console'
15
+ require "kitchen"
16
+ require "kitchen/driver/lxd/host_locator"
17
+ require "tty/reader"
18
+ require "tty/screen"
19
+ require "io/wait"
20
+ require "io/console"
21
21
 
22
22
  class NxHost
23
23
  include Kitchen::Driver::Lxd::HostLocator
@@ -38,7 +38,7 @@ end
38
38
 
39
39
  # ruby bin/lxc-shell .kitchen/kitchen-lxd-native-ubuntu-1604.yml
40
40
 
41
- term = ENV['TERM'] || 'dumb'
41
+ term = ENV["TERM"] || "dumb"
42
42
  user = transport.username
43
43
  if user
44
44
  user = " - #{user}"
@@ -1,34 +1,34 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
2
+ lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'kitchen/driver/lxd_version'
4
+ require "kitchen/driver/lxd_version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = 'kitchen-lxd_sling'
7
+ spec.name = "kitchen-lxd_sling"
8
8
  spec.version = Kitchen::Driver::LXD_VERSION
9
- spec.authors = ['Sean Zachariasen']
10
- spec.email = ['thewyzard@hotmail.com']
9
+ spec.authors = ["Sean Zachariasen"]
10
+ spec.email = ["thewyzard@hotmail.com"]
11
11
 
12
- spec.summary = 'Test Kitchen Driver for LXD'
13
- spec.homepage = 'https://github.com/NexusSW/kitchen-lxd_sling'
14
- spec.license = 'Apache-2.0'
12
+ spec.summary = "Test Kitchen Driver for LXD"
13
+ spec.homepage = "https://github.com/NexusSW/kitchen-lxd_sling"
14
+ spec.license = "Apache-2.0"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
17
  f.match(%r{^(test|spec|features)/})
18
18
  end
19
- spec.bindir = 'exe'
19
+ spec.bindir = "exe"
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
- spec.require_paths = ['lib']
21
+ spec.require_paths = ["lib"]
22
22
 
23
- spec.add_dependency 'lxd-common', '~> 0.9'
24
- spec.add_dependency 'test-kitchen', '~> 1.0'
25
- spec.add_dependency 'tty-reader', '~> 0.2'
26
- spec.add_dependency 'tty-screen', '~> 0.6'
23
+ spec.add_dependency "lxd-common", "~> 0.9"
24
+ spec.add_dependency "test-kitchen", "~> 1.0"
25
+ spec.add_dependency "tty-reader", "~> 0.2"
26
+ spec.add_dependency "tty-screen", "~> 0.6"
27
27
 
28
- spec.add_development_dependency 'bundler'
29
- spec.add_development_dependency 'rake'
30
- spec.add_development_dependency 'rspec'
31
- spec.add_development_dependency 'berkshelf'
32
- spec.add_development_dependency 'kitchen-inspec'
33
- spec.add_development_dependency 'train-lxd'
28
+ spec.add_development_dependency "bundler"
29
+ spec.add_development_dependency "rake"
30
+ spec.add_development_dependency "rspec"
31
+ spec.add_development_dependency "berkshelf"
32
+ spec.add_development_dependency "kitchen-inspec"
33
+ spec.add_development_dependency "train-lxd"
34
34
  end
@@ -1,18 +1,18 @@
1
- require 'kitchen'
2
- require 'kitchen/driver/base'
3
- require 'kitchen/transport/lxd'
4
- require 'kitchen/driver/lxd_version'
5
- require 'kitchen/driver/lxd/host_locator'
1
+ require "kitchen"
2
+ require "kitchen/driver/base"
3
+ require "kitchen/transport/lxd"
4
+ require "kitchen/driver/lxd_version"
5
+ require "kitchen/driver/lxd/host_locator"
6
6
 
7
- require 'nexussw/lxd/driver/cli'
8
- require 'nexussw/lxd/driver/rest'
9
- require 'nexussw/lxd/transport/cli'
10
- require 'nexussw/lxd/transport/rest'
11
- require 'nexussw/lxd/transport/local'
7
+ require "nexussw/lxd/driver/cli"
8
+ require "nexussw/lxd/driver/rest"
9
+ require "nexussw/lxd/transport/cli"
10
+ require "nexussw/lxd/transport/rest"
11
+ require "nexussw/lxd/transport/local"
12
12
 
13
- require 'securerandom'
13
+ require "securerandom"
14
14
 
15
- require 'kitchen/verifier/inspec-lxd'
15
+ require "kitchen/verifier/inspec-lxd"
16
16
 
17
17
  module Kitchen
18
18
  module Driver
@@ -29,12 +29,12 @@ module Kitchen
29
29
 
30
30
  default_config :server, nil
31
31
  default_config :port, 8443
32
- default_config :image_server, 'https://images.linuxcontainers.org'
32
+ default_config :image_server, "https://images.linuxcontainers.org"
33
33
  default_config :rest_options, {}
34
34
 
35
35
  def create(state)
36
36
  state[:config] = config.select { |k, _| [:server, :port, :rest_options, :image_server].include? k }
37
- info 'Utilizing REST interface at ' + host_address if respond_to?(:info) && can_rest?
37
+ info "Utilizing REST interface at " + host_address if respond_to?(:info) && can_rest?
38
38
 
39
39
  state[:username] = config[:username] if config.key? :username
40
40
  state[:container_name] = new_container_name unless state[:container_name]
@@ -45,16 +45,12 @@ module Kitchen
45
45
  info "Container name: #{state[:container_name]}"
46
46
  driver.create_container(state[:container_name], state[:container_options])
47
47
 
48
- if state[:username] && cloud_image?
49
- info 'Waiting for cloud-init...'
50
- driver.wait_for state[:container_name], :cloud_init
51
- end
52
48
  # Allow SSH transport on known images with sshd enabled
53
49
  # This will only work if the container is routable. LXD does not do port forwarding (yet)
54
50
  # 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
51
  # think ahead for default behaviour once LXD can port forward
56
52
  # 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...'
53
+ info "Waiting for an IP address..."
58
54
  state[:ip_address] = state[:hostname] = container_ip(state)
59
55
  if use_ssh?
60
56
  # Normalize [:ssh_login]
@@ -62,7 +58,13 @@ module Kitchen
62
58
  config[:ssh_login] ||= {} # if config[:ssh_login] && !config.to_hash[:ssh_login].is_a?(Hash)
63
59
 
64
60
  state[:username] = config[:ssh_login][:username] if config[:ssh_login].key? :username
65
- state[:username] ||= 'root'
61
+ state[:username] ||= "root"
62
+
63
+ if (state[:username] != "root") && cloud_image?
64
+ info "Waiting for cloud-init..."
65
+ driver.wait_for state[:container_name], :cloud_init
66
+ end
67
+
66
68
  setup_ssh(state[:username], config[:ssh_login][:public_key] || "#{ENV['HOME']}/.ssh/id_rsa.pub", state)
67
69
  info "SSH access enabled on #{state[:ip_address]}"
68
70
  else
@@ -75,9 +77,9 @@ module Kitchen
75
77
  # only centos/7 and various ubuntu versions have been tested here
76
78
  # - ubuntu non-cloud has no download utilities in order to dl the chef package so we must adapt that
77
79
  # - 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!
80
+ unless transport.execute("test -d /etc/apt").error?
81
+ info "Installing additional dependencies..."
82
+ transport.execute("apt-get install openssl curl ca-certificates -y").error!
81
83
  end
82
84
  end
83
85
  end
@@ -115,11 +117,11 @@ module Kitchen
115
117
  def cloud_image?
116
118
  server = image_server
117
119
  return false unless server && server[:server]
118
- server[:server].downcase.start_with? 'https://cloud-images.ubuntu.com'
120
+ server[:server].downcase.start_with? "https://cloud-images.ubuntu.com"
119
121
  end
120
122
 
121
123
  def new_container_name
122
- instance.name + '-' + SecureRandom.hex(8)
124
+ instance.name + "-" + SecureRandom.hex(8)
123
125
  end
124
126
 
125
127
  # Normalize into a hash with the correct protocol
@@ -132,7 +134,7 @@ module Kitchen
132
134
  server = config[:image_server]
133
135
  if server.is_a? String
134
136
  server = { server: server }
135
- server[:protocol] = 'simplestreams' if server[:server].split(':', 3)[2].nil?
137
+ server[:protocol] = "simplestreams" if server[:server].split(":", 3)[2].nil?
136
138
  end
137
139
  server
138
140
  end
@@ -149,19 +151,19 @@ module Kitchen
149
151
  return name unless server
150
152
 
151
153
  # 1:
152
- if server.downcase.start_with? 'https://cloud-images.ubuntu.com'
154
+ if server.downcase.start_with? "https://cloud-images.ubuntu.com"
153
155
  info "Using cloud-image '#{name}'"
154
- return name.downcase.sub(/^ubuntu-/, '')
156
+ return name.downcase.sub(/^ubuntu-/, "")
155
157
  end
156
158
  # 2:
157
- if server.downcase.start_with? 'https://images.linuxcontainers.org'
158
- name = name.downcase.split('-')
159
+ if server.downcase.start_with? "https://images.linuxcontainers.org"
160
+ name = name.downcase.split("-")
159
161
  # 'core' parses out in this method as the 'version' so just use 'ubuntu-core' in the kitchen.yml
160
- if UBUNTU_RELEASES.key?(name[1]) && name[0] == 'ubuntu'
162
+ if UBUNTU_RELEASES.key?(name[1]) && name[0] == "ubuntu"
161
163
  name[1] = UBUNTU_RELEASES[name[1]]
162
- name[0] = 'ubuntu-core' if name[1] == '16' # Logic patch for the edge case. We'll do something different if this gets complicated
164
+ name[0] = "ubuntu-core" if name[1] == "16" # Logic patch for the edge case. We'll do something different if this gets complicated
163
165
  end
164
- name = name.join('/')
166
+ name = name.join("/")
165
167
  info "Using standard image #{name}"
166
168
  end
167
169
  name
@@ -171,20 +173,20 @@ module Kitchen
171
173
  # leaving this mutable so that end-users can append new releases to it
172
174
  # Usage Note: If a future release is not in the below table, just specify the full image name in the kitchen yml instead of using ubuntu-<version>
173
175
  UBUNTU_RELEASES = { # rubocop:disable Style/MutableConstant
174
- '12.04' => 'precise',
175
- '14.04' => 'trusty',
176
- '16.04' => 'xenial',
177
- '17.04' => 'zesty',
178
- '17.10' => 'artful',
179
- '18.04' => 'bionic',
180
- 'core' => '16',
176
+ "12.04" => "precise",
177
+ "14.04" => "trusty",
178
+ "16.04" => "xenial",
179
+ "17.04" => "zesty",
180
+ "17.10" => "artful",
181
+ "18.04" => "bionic",
182
+ "core" => "16",
181
183
  }
182
184
 
183
185
  def container_options
184
186
  options = image_server
185
187
  # 0:
186
188
  found = false
187
- %w(:alias :fingerprint :properties).each do |k|
189
+ %w{:alias :fingerprint :properties}.each do |k|
188
190
  if config.key? k
189
191
  options[k] = config[k]
190
192
  found = true
@@ -213,9 +215,9 @@ module Kitchen
213
215
  raise
214
216
  ensure
215
217
  raise ActionFailed, "User (#{username}), or their home directory, were not found within container (#{state[:container_name]})" unless sshdir && !sshdir.empty?
216
- sshdir += '/.ssh'
218
+ sshdir += "/.ssh"
217
219
  end
218
- ak_file = sshdir + '/authorized_keys'
220
+ ak_file = sshdir + "/authorized_keys"
219
221
 
220
222
  info "Inserting public key for container user '#{username}'"
221
223
  transport.execute("bash -c 'mkdir -p #{sshdir} 2> /dev/null; cat #{remote_file} >> #{ak_file} \
@@ -1,7 +1,7 @@
1
- require 'kitchen/driver/base'
2
- require 'nexussw/lxd/transport/local'
3
- require 'nexussw/lxd/driver/cli'
4
- require 'nexussw/lxd/driver/rest'
1
+ require "kitchen/driver/base"
2
+ require "nexussw/lxd/transport/local"
3
+ require "nexussw/lxd/driver/cli"
4
+ require "nexussw/lxd/driver/rest"
5
5
 
6
6
  class Kitchen::Driver::Lxd < Kitchen::Driver::Base
7
7
  module HostLocator
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Kitchen
4
4
  module Driver
5
- LXD_VERSION = '0.5.2'.freeze
5
+ LXD_VERSION = "0.5.3".freeze
6
6
  end
7
7
  end
@@ -1,7 +1,7 @@
1
- require 'kitchen/transport/base'
2
- require 'kitchen/driver/lxd_version'
3
- require 'shellwords'
4
- require 'fileutils'
1
+ require "kitchen/transport/base"
2
+ require "kitchen/driver/lxd_version"
3
+ require "shellwords"
4
+ require "fileutils"
5
5
 
6
6
  module Kitchen
7
7
  module Transport
@@ -26,7 +26,7 @@ module Kitchen
26
26
  end
27
27
 
28
28
  def state_filename
29
- instance.instance_variable_get('@state_file').instance_variable_get('@file_name')
29
+ instance.instance_variable_get("@state_file").instance_variable_get("@file_name")
30
30
  end
31
31
 
32
32
  class Connection < Transport::Base::Connection
@@ -44,7 +44,7 @@ module Kitchen
44
44
  # There are some bash-isms coming from chef_zero (in particular, multiple_converge)
45
45
  # so let's wrap it
46
46
  command = command.shelljoin if command.is_a? Array
47
- command = ['bash', '-c', command]
47
+ command = ["bash", "-c", command]
48
48
  res = nx_transport.execute(command, capture: true) do |stdout_chunk, stderr_chunk|
49
49
  logger << stdout_chunk if stdout_chunk
50
50
  logger << stderr_chunk if stderr_chunk
@@ -75,8 +75,8 @@ module Kitchen
75
75
  end
76
76
 
77
77
  def login_command
78
- args = [File.expand_path('../../../../bin/lxc-shell', __FILE__), state_filename]
79
- LoginCommand.new 'ruby', args
78
+ args = [File.expand_path("../../../../bin/lxc-shell", __FILE__), state_filename]
79
+ LoginCommand.new "ruby", args
80
80
  end
81
81
  end
82
82
  end
@@ -1,14 +1,14 @@
1
1
 
2
- require 'kitchen/verifier/base'
2
+ require "kitchen/verifier/base"
3
3
 
4
4
  class Kitchen::Verifier::Inspec < Kitchen::Verifier::Base
5
5
  def runner_options_for_lxd(config_data)
6
- require 'train/lxd'
6
+ require "train/lxd"
7
7
  return config_data.select { |k, _| [:config, :container_name, :username].include? k }.tap do |data|
8
- data[:backend] = 'lxd'
8
+ data[:backend] = "lxd"
9
9
  data[:logger] = logger
10
10
  end
11
11
  rescue LoadError
12
- raise 'The `train-lxd` gem is required to run inspec for this container. Is it installed?'
12
+ raise "The `train-lxd` gem is required to run inspec for this container. Is it installed?"
13
13
  end
14
14
  end
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.2
4
+ version: 0.5.3
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-03-08 00:00:00.000000000 Z
11
+ date: 2018-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lxd-common
@@ -157,6 +157,7 @@ executables: []
157
157
  extensions: []
158
158
  extra_rdoc_files: []
159
159
  files:
160
+ - ".gitattributes"
160
161
  - ".gitignore"
161
162
  - ".kitchen.travis.yml"
162
163
  - ".kitchen.yml"