vagrant-lxd 0.5.0 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1baeedff522cfbebedcb5502ca770a5acee212b651cd15ee5689de902151e218
4
- data.tar.gz: a4310d180e7f8b686e474087f715fcf5896f37f51e233a934f9af156a332e633
3
+ metadata.gz: 06befa3b329e3326a09931a8b2a9697fd7f30c25d95935382eaa14fc71f55667
4
+ data.tar.gz: ed9cea092231c528d359a629b69b4c3ff847098c1e26706886a9d686df6d02b6
5
5
  SHA512:
6
- metadata.gz: c26145438faab6e93dae3e9e838d899478cac316de5d97c9ee844acbebc192d2ff8b8b324ad9099b8a50cb75ac4770f88e60a26b2646020c53fe241a958b2f14
7
- data.tar.gz: 70768153d8648bf0fc22406e9bb5107f399acac378a9ea5811955a483c11e4e0e9cb575afa8e58a9bb5e3d3844deb4cc6413a6e16001fefa8fe8ec5828be8844
6
+ metadata.gz: ed5232a956aed40892dfc03e072e42a9292ad08f24e2ea5b5a720697aad947714f7a5b6d1073e8aee5b17e21445394b1f193f6e9f23ad1ea381a3b9a7d066979
7
+ data.tar.gz: a282394ec033c9b5ca9ba5706b8d288dfb19fa6ff6d492aa06170062cf83d7eff3984d03003fec9ebdc0a00cd0ea91554e0050fce22da96d96fe0ca9acaafebb
data/.gitlab-ci.yml CHANGED
@@ -1,10 +1,11 @@
1
- image: "ruby:2.4"
1
+ image: ruby:2.5
2
2
 
3
3
  before_script:
4
4
  - apt-get -y update
5
5
  - apt-get -y upgrade
6
6
  - gem install bundler
7
- - bundle install -j $(nproc) --path vendor/bundle
7
+ - bundle config set --local path vendor/bundle
8
+ - bundle install --jobs $(nproc)
8
9
 
9
10
  spec:
10
11
  script:
data/Gemfile CHANGED
@@ -7,7 +7,7 @@ group :development do
7
7
  gem 'rspec'
8
8
  gem 'rspec-its'
9
9
  gem 'rspec-mocks'
10
- gem 'vagrant', git: 'https://github.com/mitchellh/vagrant.git'
10
+ gem 'vagrant', git: 'https://github.com/mitchellh/vagrant.git', tag: 'v2.2.15'
11
11
  end
12
12
 
13
13
  group :plugins do
data/Gemfile.lock CHANGED
@@ -1,25 +1,24 @@
1
1
  GIT
2
2
  remote: https://github.com/mitchellh/vagrant.git
3
- revision: 2063111ab5cfcce0f6b2dbcecd9d24d47b512a96
3
+ revision: 9247e07fc8ffe2fdb91c6422bbb133a25983fe15
4
+ tag: v2.2.15
4
5
  specs:
5
- vagrant (2.2.10.dev)
6
- bcrypt_pbkdf (~> 1.0.0)
6
+ vagrant (2.2.15)
7
+ bcrypt_pbkdf (~> 1.1)
7
8
  childprocess (~> 4.0.0)
8
9
  ed25519 (~> 1.2.4)
9
- erubis (~> 2.7.0)
10
+ erubi
10
11
  hashicorp-checkpoint (~> 0.1.5)
11
12
  i18n (~> 1.8)
12
- listen (~> 3.1)
13
+ listen (~> 3.4)
13
14
  log4r (~> 1.1.9, < 1.1.11)
14
- mime (~> 0.4.4)
15
+ mime-types (~> 3.3)
15
16
  net-scp (~> 1.2.0)
16
17
  net-sftp (~> 3.0)
17
- net-ssh (~> 6.0)
18
+ net-ssh (>= 6.1.0, < 7)
18
19
  rb-kqueue (~> 0.2.0)
19
- rest-client (>= 1.6.0, < 3.0)
20
- ruby_dep (<= 1.3.1)
21
20
  rubyzip (~> 2.0)
22
- vagrant_cloud (~> 2.0.3)
21
+ vagrant_cloud (~> 3.0.4)
23
22
  wdm (~> 0.1.0)
24
23
  winrm (>= 2.3.4, < 3.0)
25
24
  winrm-elevated (>= 1.2.1, < 2.0)
@@ -28,49 +27,45 @@ GIT
28
27
  PATH
29
28
  remote: .
30
29
  specs:
31
- vagrant-lxd (0.5.0)
30
+ vagrant-lxd (0.5.4)
32
31
  activesupport (~> 5.2.3)
33
32
  faraday (~> 0.17)
34
- hyperkit (~> 1.2.0)
33
+ hyperkit (~> 1.3.0)
35
34
 
36
35
  GEM
37
36
  remote: https://rubygems.org/
38
37
  specs:
39
- activesupport (5.2.4.3)
38
+ activesupport (5.2.6)
40
39
  concurrent-ruby (~> 1.0, >= 1.0.2)
41
40
  i18n (>= 0.7, < 2)
42
41
  minitest (~> 5.1)
43
42
  tzinfo (~> 1.1)
44
- addressable (2.7.0)
43
+ addressable (2.8.0)
45
44
  public_suffix (>= 2.0.2, < 5.0)
46
- bcrypt_pbkdf (1.0.1)
45
+ bcrypt_pbkdf (1.1.0)
47
46
  builder (3.2.4)
48
47
  childprocess (4.0.0)
49
- concurrent-ruby (1.1.7)
48
+ concurrent-ruby (1.1.8)
50
49
  diff-lcs (1.4.4)
51
- domain_name (0.5.20190701)
52
- unf (>= 0.0.5, < 1.0.0)
53
50
  ed25519 (1.2.4)
54
- erubi (1.9.0)
55
- erubis (2.7.0)
56
- fakefs (1.2.2)
57
- faraday (0.17.3)
51
+ erubi (1.10.0)
52
+ excon (0.79.0)
53
+ fakefs (1.3.2)
54
+ faraday (0.17.4)
58
55
  multipart-post (>= 1.2, < 3)
59
- ffi (1.13.1)
60
- gssapi (1.3.0)
56
+ ffi (1.15.0)
57
+ gssapi (1.3.1)
61
58
  ffi (>= 1.0.1)
62
59
  gyoku (1.3.1)
63
60
  builder (>= 2.1.2)
64
61
  hashicorp-checkpoint (0.1.5)
65
- http-cookie (1.0.3)
66
- domain_name (~> 0.5)
67
62
  httpclient (2.8.3)
68
- hyperkit (1.2.0)
63
+ hyperkit (1.3.0)
69
64
  activesupport (>= 4.2.6)
70
65
  sawyer
71
- i18n (1.8.5)
66
+ i18n (1.8.10)
72
67
  concurrent-ruby (~> 1.0)
73
- listen (3.2.1)
68
+ listen (3.5.1)
74
69
  rb-fsevent (~> 0.10, >= 0.10.3)
75
70
  rb-inotify (~> 0.9, >= 0.9.10)
76
71
  little-plugger (1.1.4)
@@ -78,11 +73,10 @@ GEM
78
73
  logging (2.3.0)
79
74
  little-plugger (~> 1.1)
80
75
  multi_json (~> 1.14)
81
- mime (0.4.4)
82
76
  mime-types (3.3.1)
83
77
  mime-types-data (~> 3.2015)
84
- mime-types-data (3.2020.0512)
85
- minitest (5.14.1)
78
+ mime-types-data (3.2021.0225)
79
+ minitest (5.14.4)
86
80
  multi_json (1.15.0)
87
81
  multipart-post (2.1.1)
88
82
  net-scp (1.2.1)
@@ -90,51 +84,43 @@ GEM
90
84
  net-sftp (3.0.0)
91
85
  net-ssh (>= 5.0.0, < 7.0.0)
92
86
  net-ssh (6.1.0)
93
- netrc (0.11.0)
94
87
  nori (2.6.0)
95
- public_suffix (4.0.5)
96
- rake (13.0.1)
88
+ public_suffix (4.0.6)
89
+ rake (13.0.3)
97
90
  rb-fsevent (0.10.4)
98
91
  rb-inotify (0.10.1)
99
92
  ffi (~> 1.0)
100
93
  rb-kqueue (0.2.5)
101
94
  ffi (>= 0.5.0)
102
- rest-client (2.0.2)
103
- http-cookie (>= 1.0.2, < 2.0)
104
- mime-types (>= 1.16, < 4.0)
105
- netrc (~> 0.8)
106
- rspec (3.9.0)
107
- rspec-core (~> 3.9.0)
108
- rspec-expectations (~> 3.9.0)
109
- rspec-mocks (~> 3.9.0)
110
- rspec-core (3.9.2)
111
- rspec-support (~> 3.9.3)
112
- rspec-expectations (3.9.2)
95
+ rspec (3.10.0)
96
+ rspec-core (~> 3.10.0)
97
+ rspec-expectations (~> 3.10.0)
98
+ rspec-mocks (~> 3.10.0)
99
+ rspec-core (3.10.1)
100
+ rspec-support (~> 3.10.0)
101
+ rspec-expectations (3.10.1)
113
102
  diff-lcs (>= 1.2.0, < 2.0)
114
- rspec-support (~> 3.9.0)
103
+ rspec-support (~> 3.10.0)
115
104
  rspec-its (1.3.0)
116
105
  rspec-core (>= 3.0.0)
117
106
  rspec-expectations (>= 3.0.0)
118
- rspec-mocks (3.9.1)
107
+ rspec-mocks (3.10.2)
119
108
  diff-lcs (>= 1.2.0, < 2.0)
120
- rspec-support (~> 3.9.0)
121
- rspec-support (3.9.3)
122
- ruby_dep (1.3.1)
123
- rubyntlm (0.6.2)
109
+ rspec-support (~> 3.10.0)
110
+ rspec-support (3.10.2)
111
+ rubyntlm (0.6.3)
124
112
  rubyzip (2.3.0)
125
113
  sawyer (0.8.2)
126
114
  addressable (>= 2.3.5)
127
115
  faraday (> 0.8, < 2.0)
128
116
  thread_safe (0.3.6)
129
- tzinfo (1.2.7)
117
+ tzinfo (1.2.9)
130
118
  thread_safe (~> 0.1)
131
- unf (0.1.4)
132
- unf_ext
133
- unf_ext (0.0.7.7)
134
- vagrant_cloud (2.0.3)
135
- rest-client (~> 2.0.2)
119
+ vagrant_cloud (3.0.4)
120
+ excon (~> 0.73)
121
+ log4r (~> 1.1.10)
136
122
  wdm (0.1.1)
137
- winrm (2.3.4)
123
+ winrm (2.3.6)
138
124
  builder (>= 2.1.2)
139
125
  erubi (~> 1.8)
140
126
  gssapi (~> 1.2)
@@ -142,12 +128,12 @@ GEM
142
128
  httpclient (~> 2.2, >= 2.2.0.2)
143
129
  logging (>= 1.6.1, < 3.0)
144
130
  nori (~> 2.0)
145
- rubyntlm (~> 0.6.0, >= 0.6.1)
146
- winrm-elevated (1.2.1)
131
+ rubyntlm (~> 0.6.0, >= 0.6.3)
132
+ winrm-elevated (1.2.3)
147
133
  erubi (~> 1.8)
148
134
  winrm (~> 2.0)
149
135
  winrm-fs (~> 1.0)
150
- winrm-fs (1.3.4)
136
+ winrm-fs (1.3.5)
151
137
  erubi (~> 1.8)
152
138
  logging (>= 1.6.1, < 3.0)
153
139
  rubyzip (~> 2.0)
data/README.md CHANGED
@@ -236,6 +236,24 @@ folders](#synced-folders) rather than ad-hoc devices.
236
236
 
237
237
  [device-config]: https://lxd.readthedocs.io/en/latest/instances/#devices-configuration
238
238
 
239
+ ### Container Configuration
240
+
241
+ You can pass custom key/value configuration using the `config` setting. This
242
+ should be a map of [instance settings][instance-config], which will be wired
243
+ directly through to the container:
244
+
245
+ config.vm.provider 'lxd' do |lxd|
246
+ lxd.config = {
247
+ 'linux.kernel_modules': 'ip_tables,ip6_tables,netlink_diag,nf_nat,overlay',
248
+ }
249
+ end
250
+
251
+ Not all instance settings make sense in the Vagrant context, and some will or
252
+ won't work based on your LXD host's configuration, so making sure the config is
253
+ valid is up to you.
254
+
255
+ [instance-config]: https://lxd.readthedocs.io/en/latest/instances/#keyvalue-configuration
256
+
239
257
  ## Hacking
240
258
 
241
259
  To run Vagrant with the plugin automatically loaded, you can use the
@@ -9,7 +9,46 @@ Specifically, the following settings need to be applied:
9
9
  3. Your user must be in the "lxd" group.
10
10
  4. Your user must have a client certificate registered with LXD.
11
11
 
12
- ## Xenial
12
+ ## Ubuntu Focal and Later
13
+
14
+ On Ubuntu 20.04 and later, LXD is installed as a [Snap][]. To install
15
+ and configure it as described above, you can use the following commands:
16
+
17
+ ```sh
18
+ # install lxd
19
+ sudo apt install -y lxd
20
+
21
+ # enable https api access
22
+ sudo lxd init --auto --network-address=127.0.0.1 --network-port=8443
23
+
24
+ # add your user to the lxd group
25
+ sudo usermod -a -G lxd $(whoami)
26
+
27
+ # apply the new group membership
28
+ newgrp lxd
29
+ ```
30
+
31
+ Then, the first time you run Vagrant in a project that uses the LXD
32
+ provider, it will generate a client certificate for the plugin to use
33
+ and instruct you to add it to LXD with the following message:
34
+
35
+ ```
36
+ You may need configure LXD to allow requests from this machine. The
37
+ easiest way to do this is to add your LXC client certificate to LXD's
38
+ list of trusted certificates. This can typically be done with the
39
+ following command:
40
+
41
+ $ lxc config trust add ~/.vagrant.d/data/lxd/client.crt
42
+
43
+ You can find more information about configuring LXD at:
44
+
45
+ https://linuxcontainers.org/lxd/getting-started-cli/#initial-configuration
46
+ ```
47
+
48
+ Once you run that command as instructed, everything should be set up for
49
+ the plugin to work correctly.
50
+
51
+ ## Ubuntu Xenial
13
52
 
14
53
  To install LXD and configure it as described above on Ubuntu 16.04, you
15
54
  can use the following commands:
@@ -25,7 +64,7 @@ sudo lxd init --auto --network-address=127.0.0.1 --network-port=8443
25
64
  sudo dpkg-reconfigure -p medium lxd
26
65
 
27
66
  # add your user to the lxd group
28
- sudo usermod -a lxd -G $(whoami)
67
+ sudo usermod -a -G lxd $(whoami)
29
68
  ```
30
69
 
31
70
  Once LXD is configured, you should register a client certificate for
@@ -37,7 +76,7 @@ automatically generate the certificate for you):
37
76
  newgrp lxd
38
77
 
39
78
  # create and add a client certificate
40
- lxc config trust add /home/ubuntu/.config/lxc/client.crt
79
+ lxc config trust add ~/.config/lxc/client.crt
41
80
  ```
42
81
 
43
82
  At this point everything should be set up for the plugin to work
@@ -53,5 +92,6 @@ If you're using the plugin on another platform, please feel free to
53
92
  propose an addition to this document or add instructions to the
54
93
  project's [wiki][] for others to follow.
55
94
 
95
+ [Snap]: https://snapcraft.io/
56
96
  [getting-started-cli]: https://linuxcontainers.org/lxd/getting-started-cli/
57
97
  [wiki]: https://gitlab.com/catalyst-it/vagrant-lxd/wikis
@@ -95,6 +95,24 @@ module VagrantLXD
95
95
  end
96
96
  end
97
97
 
98
+ #
99
+ # Remove all files from the provider's data directory.
100
+ #
101
+ class RemoveData
102
+ include FileUtils
103
+
104
+ def initialize(app, env)
105
+ @app = app
106
+ end
107
+
108
+ def call(env)
109
+ @app.call(env)
110
+ ensure
111
+ rm_rf(env[:machine].data_dir)
112
+ mkdir_p(env[:machine].data_dir)
113
+ end
114
+ end
115
+
98
116
  #
99
117
  # Issue a warning when the machine wants synced folders but the host
100
118
  # doesn't support it (according to the relevant shadow files).
@@ -125,6 +143,8 @@ module VagrantLXD
125
143
  end
126
144
 
127
145
  class Package
146
+ include FileUtils
147
+
128
148
  def initialize(app, env)
129
149
  @app = app
130
150
  @env = env
@@ -134,7 +154,7 @@ module VagrantLXD
134
154
  env['package.directory'] = env[:machine_package]
135
155
  @app.call(env)
136
156
  ensure
137
- FileUtils.rm_rf(env[:machine_package])
157
+ rm_rf(env[:machine_package])
138
158
  end
139
159
  end
140
160
 
@@ -180,6 +200,7 @@ module VagrantLXD
180
200
  d.use halt
181
201
  d.use Message, :info, 'Destroying machine and associated data...'
182
202
  d.use LXD.action(:destroy)
203
+ d.use RemoveData
183
204
  else
184
205
  d.use Message, :info, 'Machine will not be destroyed.'
185
206
  end
@@ -119,45 +119,6 @@ module VagrantLXD
119
119
  end
120
120
  end
121
121
 
122
- module Hyperkit::Client::Containers
123
- alias extract_container_options_without_devices extract_container_options
124
-
125
- def extract_container_options(name, options)
126
- opts = extract_container_options_without_devices(name, options)
127
- options.slice(:devices).merge(opts)
128
- end
129
- end
130
-
131
- # XXX This monkey patch has the fix from https://github.com/jeffshantz/hyperkit/pull/15
132
- # TODO Remove this once there is a new release of the hyperkit gem.
133
- module Hyperkit::Connection
134
- def sawyer_options
135
- opts = {
136
- :links_parser => Sawyer::LinkParsers::Simple.new,
137
- }
138
- conn_opts = {}
139
- conn_opts[:builder] = @middleware if @middleware
140
- conn_opts[:proxy] = @proxy if @proxy
141
-
142
- conn_opts[:ssl] = {
143
- verify: verify_ssl
144
- }
145
-
146
- if client_cert && File.exist?(client_cert)
147
- conn_opts[:ssl][:client_cert] = OpenSSL::X509::Certificate.new(File.read(client_cert))
148
- end
149
-
150
- # XXX https://github.com/jeffshantz/hyperkit/pull/15/files
151
- if client_key && File.exist?(client_key)
152
- conn_opts[:ssl][:client_key] = OpenSSL::PKey.read(File.read(client_key))
153
- end
154
-
155
- opts[:faraday] = Faraday.new(conn_opts)
156
-
157
- opts
158
- end
159
- end
160
-
161
122
  NOT_CREATED = Vagrant::MachineState::NOT_CREATED_ID
162
123
 
163
124
  attr_reader :api_endpoint
@@ -200,7 +161,7 @@ module VagrantLXD
200
161
 
201
162
  def synced_folders_usable?
202
163
  # Check whether we've registered an idmap for the current user.
203
- raw_idmap = container[:config][:'raw.idmap']
164
+ raw_idmap = config[:'raw.idmap']
204
165
  begin
205
166
  raw_idmap and
206
167
  id_in_map?(Process.uid, 'uid', raw_idmap) and
@@ -569,6 +530,8 @@ module VagrantLXD
569
530
  # If the user has already specified a 'raw.idmap', leave it alone.
570
531
  if config.include?(:'raw.idmap')
571
532
  # Manually specified, carry on.
533
+ elsif @machine.config.vm.synced_folders.reject { |_, f| f[:disabled] }.empty?
534
+ # No synced folders configured, carry on.
572
535
  elsif @machine.env.host.capability(:synced_folders)
573
536
  config[:'raw.idmap'] = ''
574
537
  config[:'raw.idmap'] << "uid #{Process.uid} #{vagrant_uid}\n"
@@ -23,6 +23,7 @@ module VagrantLXD
23
23
  class Provider < Vagrant.plugin('2', :provider)
24
24
  def initialize(machine)
25
25
  @machine = machine
26
+ @driver = Driver.new(machine)
26
27
  end
27
28
 
28
29
  def action(name)
@@ -30,16 +31,14 @@ module VagrantLXD
30
31
  end
31
32
 
32
33
  def state
33
- env = @machine.action('state', lock: false)
34
- state = env[:machine_state]
34
+ state = @driver.state
35
35
  short = state.to_s.gsub('_', ' ')
36
36
  long = I18n.t("vagrant.commands.status.#{state}")
37
37
  Vagrant::MachineState.new(state, short, long)
38
38
  end
39
39
 
40
40
  def ssh_info
41
- env = @machine.action('info', lock: false)
42
- env[:machine_info]
41
+ @driver.info
43
42
  end
44
43
 
45
44
  def to_s
@@ -24,6 +24,7 @@ module VagrantLXD
24
24
 
25
25
  def usable?(machine, raise_error = false)
26
26
  return false unless machine.provider_name == :lxd
27
+ return false unless machine.env.host.capability(:synced_folders)
27
28
 
28
29
  @driver ||= Driver.new(machine)
29
30
 
@@ -20,7 +20,7 @@
20
20
  module VagrantLXD
21
21
  module Version
22
22
  NAME = 'vagrant-lxd'
23
- VERSION = '0.5.0'
23
+ VERSION = '0.5.4'
24
24
  DESCRIPTION = 'Vagrant LXD provider'
25
25
  end
26
26
  end
data/vagrant-lxd.gemspec CHANGED
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
36
36
  end
37
37
 
38
38
  spec.add_runtime_dependency 'activesupport', '~> 5.2.3'
39
- spec.add_runtime_dependency 'hyperkit', '~> 1.2.0'
39
+ spec.add_runtime_dependency 'hyperkit', '~> 1.3.0'
40
40
 
41
41
  # NOTE fixed to preserve ruby 1.x compatibility, versions after 1.0
42
42
  # use the safe navigation operator and thus need ruby 2.3 or newer
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-lxd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Hanson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-03 00:00:00.000000000 Z
11
+ date: 2021-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.2.0
33
+ version: 1.3.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.2.0
40
+ version: 1.3.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: faraday
43
43
  requirement: !ruby/object:Gem::Requirement