vagrant-k3s 0.1.3 → 0.1.4.dev.1

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: 48811d5faa2c2744a08194bd9363f10e799e1b54cba87032cfba59dad23cf225
4
- data.tar.gz: be610cfd383841a2ae5835bda38641121113945212846c21d8a2870073bd1016
3
+ metadata.gz: 00ca7014365cb6c5c35f8ed43d8d2dbc92a091e87435d4db3a02521561fc6946
4
+ data.tar.gz: fe75bb00f31e7b82b94db3a3353733e96b4b2c5bbf5c02dd5c36e8d04022490c
5
5
  SHA512:
6
- metadata.gz: 6f55e634c9e2f24d4e74f93e7d5fc3432636c7deea33fbe4b0d8c8c331954d877824dc6fce8e718206f2957d6f503c48120e05c434fe558053cf33c58010854d
7
- data.tar.gz: 4cb146976504bc739e6d0d004dd6cb3246b38819667150187d0f67d5c027dc44344a46999fc6bdf84fedb1f46883ae9fc7d92f227f928a561956347d2ffc3c6d
6
+ metadata.gz: aa3bae13f3cbafedd8e7c8ab9f9d8dcc81f127e8abc9bc0df27b71fd3764e491f9929f2961caaebbb4284589079741ab86397915178da8efa8037b441f2a2cd0
7
+ data.tar.gz: d3efba057d5e2543e7dc671095923559d58896bfd5b67fe68129ebe70670a01887ab06ce74f44adfdd12cfb0de8055259646ef2d5feb6e495c53c46cfc876f05
data/Gemfile CHANGED
@@ -8,11 +8,8 @@ end
8
8
 
9
9
  group :plugins do
10
10
  gemspec
11
- gem "vagrant-aws"
12
- gem "vagrant-digitalocean"
13
- gem "vagrant-env"
14
- gem "vagrant-libvirt"
15
- gem "vagrant-reload"
16
- gem "vagrant-timezone"
17
- gem "vagrant-vmware-desktop"
11
+ # gem "vagrant-libvirt"
12
+ # gem "vagrant-reload"
13
+ # gem "vagrant-timezone"
14
+ # gem "vagrant-vmware-desktop"
18
15
  end
data/Gemfile.lock CHANGED
@@ -28,7 +28,7 @@ GIT
28
28
  PATH
29
29
  remote: .
30
30
  specs:
31
- vagrant-k3s (0.1.3)
31
+ vagrant-k3s (0.1.4.dev.1)
32
32
 
33
33
  GEM
34
34
  remote: https://rubygems.org/
@@ -38,66 +38,18 @@ GEM
38
38
  childprocess (4.1.0)
39
39
  concurrent-ruby (1.1.9)
40
40
  diff-lcs (1.4.4)
41
- dotenv (0.11.1)
42
- dotenv-deployment (~> 0.0.2)
43
- dotenv-deployment (0.0.2)
44
41
  ed25519 (1.2.4)
45
42
  erubi (1.10.0)
46
43
  excon (0.88.0)
47
- faraday (1.8.0)
48
- faraday-em_http (~> 1.0)
49
- faraday-em_synchrony (~> 1.0)
50
- faraday-excon (~> 1.1)
51
- faraday-httpclient (~> 1.0.1)
52
- faraday-net_http (~> 1.0)
53
- faraday-net_http_persistent (~> 1.1)
54
- faraday-patron (~> 1.0)
55
- faraday-rack (~> 1.0)
56
- multipart-post (>= 1.2, < 3)
57
- ruby2_keywords (>= 0.0.4)
58
- faraday-em_http (1.0.0)
59
- faraday-em_synchrony (1.0.0)
60
- faraday-excon (1.1.0)
61
- faraday-httpclient (1.0.1)
62
- faraday-net_http (1.0.1)
63
- faraday-net_http_persistent (1.2.0)
64
- faraday-patron (1.0.0)
65
- faraday-rack (1.0.0)
66
44
  ffi (1.15.4)
67
- fog-aws (3.12.0)
68
- fog-core (~> 2.1)
69
- fog-json (~> 1.1)
70
- fog-xml (~> 0.1)
71
- ipaddress (~> 0.8)
72
- fog-core (2.2.4)
73
- builder
74
- excon (~> 0.71)
75
- formatador (~> 0.2)
76
- mime-types
77
- fog-json (1.2.0)
78
- fog-core
79
- multi_json (~> 1.10)
80
- fog-libvirt (0.9.0)
81
- fog-core (>= 1.27.4)
82
- fog-json
83
- fog-xml (~> 0.1.1)
84
- json
85
- ruby-libvirt (>= 0.7.0)
86
- fog-xml (0.1.4)
87
- fog-core
88
- nokogiri (>= 1.5.11, < 2.0.0)
89
- formatador (0.3.0)
90
45
  gssapi (1.3.1)
91
46
  ffi (>= 1.0.1)
92
47
  gyoku (1.3.1)
93
48
  builder (>= 2.1.2)
94
49
  hashicorp-checkpoint (0.1.5)
95
50
  httpclient (2.8.3)
96
- i18n (1.8.10)
51
+ i18n (1.8.11)
97
52
  concurrent-ruby (~> 1.0)
98
- iniparse (1.5.0)
99
- ipaddress (0.8.3)
100
- json (2.6.1)
101
53
  listen (3.7.0)
102
54
  rb-fsevent (~> 0.10, >= 0.10.3)
103
55
  rb-inotify (~> 0.9, >= 0.9.10)
@@ -106,20 +58,16 @@ GEM
106
58
  logging (2.3.0)
107
59
  little-plugger (~> 1.1)
108
60
  multi_json (~> 1.14)
109
- mime-types (3.3.1)
61
+ mime-types (3.4.1)
110
62
  mime-types-data (~> 3.2015)
111
- mime-types-data (3.2021.0901)
63
+ mime-types-data (3.2021.1115)
112
64
  multi_json (1.15.0)
113
- multipart-post (2.1.1)
114
65
  net-scp (3.0.0)
115
66
  net-ssh (>= 2.6.5, < 7.0.0)
116
67
  net-sftp (3.0.0)
117
68
  net-ssh (>= 5.0.0, < 7.0.0)
118
69
  net-ssh (6.1.0)
119
- nokogiri (1.12.5-x86_64-linux)
120
- racc (~> 1.4)
121
70
  nori (2.6.0)
122
- racc (1.6.0)
123
71
  rake (13.0.6)
124
72
  rb-fsevent (0.11.0)
125
73
  rb-inotify (0.10.1)
@@ -139,28 +87,9 @@ GEM
139
87
  rspec-mocks (3.10.2)
140
88
  diff-lcs (>= 1.2.0, < 2.0)
141
89
  rspec-support (~> 3.10.0)
142
- rspec-support (3.10.2)
143
- ruby-libvirt (0.7.1)
144
- ruby2_keywords (0.0.5)
90
+ rspec-support (3.10.3)
145
91
  rubyntlm (0.6.3)
146
92
  rubyzip (2.3.2)
147
- vagrant-aws (0.7.2)
148
- fog-aws (~> 3.12.0)
149
- iniparse (~> 1.4, >= 1.4.2)
150
- vagrant-digitalocean (0.9.5)
151
- faraday (>= 0.8.6)
152
- json
153
- log4r
154
- vagrant-env (0.0.3)
155
- dotenv (~> 0.9)
156
- vagrant-libvirt (0.6.3)
157
- fog-core (~> 2.1)
158
- fog-libvirt (>= 0.6.0)
159
- nokogiri (~> 1.6)
160
- rexml
161
- vagrant-reload (0.0.1)
162
- vagrant-timezone (1.3.0)
163
- vagrant-vmware-desktop (3.0.1)
164
93
  vagrant_cloud (3.0.5)
165
94
  excon (~> 0.73)
166
95
  log4r (~> 1.1.10)
@@ -192,14 +121,7 @@ DEPENDENCIES
192
121
  rake (~> 13.0)
193
122
  rspec (~> 3.10.0)
194
123
  vagrant!
195
- vagrant-aws
196
- vagrant-digitalocean
197
- vagrant-env
198
124
  vagrant-k3s!
199
- vagrant-libvirt
200
- vagrant-reload
201
- vagrant-timezone
202
- vagrant-vmware-desktop
203
125
 
204
126
  BUNDLED WITH
205
127
  2.2.27
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module VagrantPlugins
4
+ module K3s
5
+ module Cap
6
+ module Linux
7
+ module K3sKubectl
8
+ def self.k3s_kubectl(machine,*args)
9
+ cmd = "k3s kubectl #{args.join(' ')}"
10
+ machine.ui.info cmd
11
+ begin
12
+ machine.communicate.execute(cmd) do |type, data|
13
+ machine.ui.detail data.chomp, :color => type == :stderr ? :red : :green
14
+ end
15
+ rescue Vagrant::Errors::VagrantError
16
+ return 0
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -3,16 +3,18 @@
3
3
  module VagrantPlugins
4
4
  module K3s
5
5
  class Config < Vagrant.plugin(2, :config)
6
- DEFAULT_CONFIG_MODE = "0600".freeze
7
- DEFAULT_CONFIG_OWNER = "root:root".freeze
8
- DEFAULT_CONFIG_PATH = "/etc/rancher/k3s/config.yaml".freeze
9
- DEFAULT_ENV_MODE = "0600".freeze
10
- DEFAULT_ENV_OWNER = "root:root".freeze
11
- DEFAULT_ENV_PATH = "/etc/rancher/k3s/install.env".freeze
12
- DEFAULT_INSTALLER_URL = "https://get.k3s.io".freeze
6
+ DEFAULT_FILE_MODE = '0600'
7
+ DEFAULT_FILE_OWNER = 'root:root'
8
+ DEFAULT_CONFIG_MODE = DEFAULT_FILE_MODE
9
+ DEFAULT_CONFIG_OWNER = DEFAULT_FILE_OWNER
10
+ DEFAULT_CONFIG_PATH = '/etc/rancher/k3s/config.yaml'
11
+ DEFAULT_ENV_MODE = DEFAULT_FILE_MODE
12
+ DEFAULT_ENV_OWNER = DEFAULT_FILE_OWNER
13
+ DEFAULT_ENV_PATH = '/etc/rancher/k3s/install.env'
14
+ DEFAULT_INSTALLER_URL = 'https://get.k3s.io'
13
15
 
14
16
  # string or array
15
- # @return [Array<String]
17
+ # @return [Array<String>]
16
18
  attr_accessor :args
17
19
 
18
20
  # string (.yaml) or hash
@@ -28,6 +28,11 @@ module VagrantPlugins
28
28
  Cap::Linux::K3sInstalled
29
29
  end
30
30
 
31
+ guest_capability(:linux, :k3s_kubectl) do
32
+ require_relative "cap/linux/k3s_kubectl"
33
+ Cap::Linux::K3sKubectl
34
+ end
35
+
31
36
  guest_capability(:linux, :curl_installed) do
32
37
  require_relative "cap/linux/curl_installed"
33
38
  Cap::Linux::CurlInstalled
@@ -14,12 +14,11 @@ module VagrantPlugins
14
14
  @logger = Log4r::Logger.new("vagrant::provisioners::k3s")
15
15
  end
16
16
 
17
- def configure(root_config)
18
- @logger.debug root_config.inspect
19
- end
17
+ # def configure(root)
18
+ # end
20
19
 
21
- def cleanup
22
- end
20
+ # def cleanup
21
+ # end
23
22
 
24
23
  def provision
25
24
  args = ""
@@ -30,34 +29,32 @@ module VagrantPlugins
30
29
  args = " #{args.join(" ")}"
31
30
  end
32
31
 
33
- @machine.ui.info 'Installing K3s ...'
34
-
35
32
  unless @machine.guest.capability(:curl_installed)
33
+ @machine.ui.info 'Installing Curl ...'
36
34
  @machine.guest.capability(:curl_install)
37
35
  end
38
36
 
39
- config_file = config.config_path.to_s
40
- config_yaml = config.config.is_a?(String) ? config.config : stringify_keys(config.config).to_yaml
41
- with_file_upload "k3s-config.yaml".freeze, config_file, config_yaml
37
+ cfg_file = config.config_path.to_s
38
+ cfg_yaml = config.config.is_a?(String) ? config.config : stringify_keys(config.config).to_yaml
39
+ file_upload "k3s-config.yaml", cfg_file, cfg_yaml
42
40
 
43
- install_env_file = config.env_path.to_s
44
- install_env_text = ""
41
+ env_file = config.env_path.to_s
42
+ env_text = ""
45
43
  if config.env.is_a?(String)
46
- install_env_text = config.env.to_s
44
+ env_text = config.env.to_s
47
45
  end
48
46
  if config.env.is_a?(Array)
49
- config.env.each {|line| install_env_text << "#{line.to_s}\n"}
47
+ config.env.each {|line| env_text << "#{line.to_s}\n"}
50
48
  end
51
49
  if config.env.is_a?(Hash)
52
- config.env.each {|key,value| install_env_text << "#{key.to_s}=#{quote_and_escape(value.to_s)}\n"}
50
+ config.env.each {|key,value| env_text << "#{key.to_s}=#{quote_and_escape(value.to_s)}\n"}
53
51
  end
54
- with_file_upload "k3s-install.env".freeze, install_env_file, install_env_text
52
+ file_upload "k3s-install.env", env_file, env_text
55
53
 
56
- install_sh = "/tmp/vagrant-k3s-provisioner-install.sh".freeze
57
- with_file_upload "k3s-install.sh", install_sh, <<~EOF
54
+ prv_file = "/vagrant/k3s-provisioner.sh"
55
+ prv_text = <<~EOF
58
56
  #/usr/bin/env bash
59
57
  set -eu -o pipefail
60
- mkdir -m 0755 -p $(dirname #{config.config_path}) $(dirname #{config.env_path})
61
58
  chown #{config.config_owner} #{config.config_path}
62
59
  chmod #{config.config_mode} #{config.config_path}
63
60
  chown #{config.env_owner} #{config.env_path}
@@ -65,11 +62,14 @@ module VagrantPlugins
65
62
  set -o allexport
66
63
  source #{config.env_path}
67
64
  set +o allexport
68
- curl -fsL #{config.installer_url} | sh -s - #{args}
65
+ curl -fsL '#{config.installer_url}' | sh -s - #{args}
69
66
  EOF
67
+ file_upload("k3s-install.sh", prv_file, prv_text)
68
+ @machine.ui.info "Invoking: #{prv_file}"
69
+
70
70
  outputs, handler = build_outputs
71
71
  begin
72
- @machine.communicate.sudo("chmod +x #{install_sh} && #{install_sh}", error_key: :ssh_bad_exit_status_muted, &handler)
72
+ @machine.communicate.sudo("chmod +x #{prv_file} && #{prv_file}", error_key: :ssh_bad_exit_status_muted, &handler)
73
73
  ensure
74
74
  outputs.values.map(&:close)
75
75
  end
@@ -85,7 +85,7 @@ module VagrantPlugins
85
85
  else
86
86
  outputs, handler = build_outputs
87
87
  begin
88
- @machine.communicate.execute("#{exe} --version", :error_key => :ssh_bad_exit_status_muted, &handler)
88
+ @machine.communicate.sudo("#{exe} --version", :error_key => :ssh_bad_exit_status_muted, &handler)
89
89
  ensure
90
90
  outputs.values.map(&:close)
91
91
  end
@@ -114,7 +114,7 @@ module VagrantPlugins
114
114
  end
115
115
  end
116
116
 
117
- def with_file(name='vagrant-k3s-provisioner', content)
117
+ def with_file(name, content)
118
118
  file = Tempfile.new([name])
119
119
  file.binmode
120
120
  begin
@@ -128,14 +128,17 @@ module VagrantPlugins
128
128
  end
129
129
  end
130
130
 
131
- def with_file_upload(name='vagrant-k3s-provisioner', to, content)
132
- with_file(name, content) do |from|
133
- tmpdir = @machine.guest.capability :create_tmp_path, {:type => :directory}
134
- tmpfile = [tmpdir, File.basename(to)].join('/')
135
- @machine.communicate.upload(from, tmpfile)
136
- @machine.communicate.sudo("mkdir -m 0755 -p #{File.dirname(to)} && mv -f #{tmpfile} #{to}")
131
+ def file_upload(local_file, remote_path, content)
132
+ with_file(local_file, content) do |local_path|
133
+ remote_tmp_dir = @machine.guest.capability :create_tmp_path, {:type => :directory}
134
+ remote_tmp_path = [remote_tmp_dir, File.basename(remote_path)].join('/')
135
+ @machine.communicate.upload(local_path, remote_tmp_path)
136
+ @machine.communicate.sudo("install -v -DTZ #{remote_tmp_path} #{remote_path}") do |type, line|
137
+ @machine.ui.info line.chomp, :color => {:stderr => :red, :stdout => :default}[type]
138
+ end
137
139
  end
138
- to
140
+ @machine.ui.detail content.chomp, :color => :yellow
141
+ remote_path
139
142
  end
140
143
 
141
144
  def quote_and_escape(text, quote = '"')
@@ -2,6 +2,6 @@
2
2
 
3
3
  module VagrantPlugins
4
4
  module K3s
5
- VERSION = '0.1.3'
5
+ VERSION = '0.1.4.dev.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-k3s
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4.dev.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacob Blain Christen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-28 00:00:00.000000000 Z
11
+ date: 2021-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -59,6 +59,7 @@ files:
59
59
  - lib/vagrant-k3s/cap/debian/curl_install.rb
60
60
  - lib/vagrant-k3s/cap/linux/curl_installed.rb
61
61
  - lib/vagrant-k3s/cap/linux/k3s_installed.rb
62
+ - lib/vagrant-k3s/cap/linux/k3s_kubectl.rb
62
63
  - lib/vagrant-k3s/cap/redhat/curl_install.rb
63
64
  - lib/vagrant-k3s/cap/suse/curl_install.rb
64
65
  - lib/vagrant-k3s/command.rb