vagrant-rke2 0.1.1 → 0.1.5

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: 3cf49d824ed2271d901c4f58c230a6f071146545615ab847f099a01725e81286
4
- data.tar.gz: 2bbfe012a5180f083cc8b09c91f7e11d200744de497120d9de65a57759cd8875
3
+ metadata.gz: b838e8def0fb51bb79dcb0bb72a2ddface01f74dbcdd169a55cbdee901d80c07
4
+ data.tar.gz: 595aa43091f782c45fb012c5be3ef43b88fd52161cfae526aec72fde39f74556
5
5
  SHA512:
6
- metadata.gz: 972ff4e827f656951d83b61abef0c670fa25e49083031f1a760bf756d08770c74c32c0e3e387d1d01ecea29d5897f89e456e54086d105a15557de9b44c923202
7
- data.tar.gz: '04043292575ed63d8655e0a9433484774cbf96bd14ef40f08293dac8c90758ceb1e7401ac47866c20bb0167d48146d1767f24d2dc432bd07a45f46561fdc3819'
6
+ metadata.gz: 4c68abdb236886bcd516f993072be888f16025501b4f05c86bd57c220b272f94391e3a20bc1a2f4e7f27fe658e700e33c4a072971d01e04a70bf232b2fbb34df
7
+ data.tar.gz: 69c5fe349a1b8ee5724e4d0809ccae89d643568521af6b0c33880f078ca73abff2ae340830c36d1e86818a0c18eb6796854e60de587d0ebc96f87e06801f11c6
data/Gemfile.lock CHANGED
@@ -28,7 +28,7 @@ GIT
28
28
  PATH
29
29
  remote: .
30
30
  specs:
31
- vagrant-rke2 (0.1.1)
31
+ vagrant-rke2 (0.1.5)
32
32
 
33
33
  GEM
34
34
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # Vagrant::RKE2
2
- This plugin was heavily inspired by the [vagrant-k3s](https://github.com/dweomer/vagrant-k3s) plugin. Check that out and give dweomer some stars.
2
+ This plugin is the companion to the [vagrant-k3s](https://github.com/k3s-io/vagrant-k3s) plugin. It makes deploying RKE2 on vagrant boxes much easier.
3
3
 
4
4
  ## Installation
5
5
 
6
+ Vagrant must be >= v2.2.17
7
+
6
8
  ```shell
7
9
  vagrant plugin install vagrant-rke2
8
10
  vagrant up --provider=<your favorite provider>
@@ -10,8 +12,11 @@ vagrant up --provider=<your favorite provider>
10
12
 
11
13
  ## Usage
12
14
 
15
+ See the [Vagrantfile](./test/Vagrantfile) for a working example.
16
+
13
17
  ### Linux VMs
14
18
  ```ruby
19
+ Vagrant.require_version ">= 2.2.17"
15
20
  Vagrant.configure("2") do |config|
16
21
  config.vm.box = 'generic/ubuntu2004'
17
22
 
@@ -49,10 +54,15 @@ Vagrant.configure("2") do |config|
49
54
  rke2.config_mode = '0644' # side-step https://github.com/k3s-io/k3s/issues/4321
50
55
  rke2.config_owner = 'root:root' #default
51
56
 
52
- # install_kubectl: QOL feature, installs latest version of kubectl
57
+ # install_path: QOL feature, add RKE2 to the PATH and points the KUBECONFIG to rke2.yaml
53
58
  # type => Boolean
54
59
  # default => true
55
- rke2.install_kubectl = false
60
+ rke2.install_path = false
61
+
62
+ # skip_start: install but don't start RKE2
63
+ # type => Boolean
64
+ # default => false
65
+ rke2.skip_start = true
56
66
  end
57
67
  end
58
68
  ```
@@ -60,6 +70,7 @@ end
60
70
  ### Windows VMs
61
71
  Windows setup is much more restricted. See https://docs.rke2.io/install/install_options/windows_agent_config/ for more info
62
72
  ```ruby
73
+ Vagrant.require_version ">= 2.2.17"
63
74
  Vagrant.configure("2") do |config|
64
75
  config.vm.box = "StefanScherer/windows_2019"
65
76
  config.vm.communicator = "winrm"
@@ -84,6 +95,16 @@ Vagrant.configure("2") do |config|
84
95
  server: https://172.168.1.200:9345
85
96
  token: vagrant-rke2
86
97
  YAML
98
+
99
+ # install_path: QOL feature, add RKE2 to the PATH
100
+ # type => Boolean
101
+ # default => true
102
+ rke2.install_path = false
103
+
104
+ # skip_start: install but don't start RKE2
105
+ # type => Boolean
106
+ # default => false
107
+ rke2.skip_start = true
87
108
  end
88
109
  end
89
110
  ```
@@ -0,0 +1,5 @@
1
+ Write-Host "Creating RKE2 environment variables..."
2
+ $env:PATH+=";C:\var\lib\rancher\rke2\bin;c:\usr\local\bin"
3
+ [Environment]::SetEnvironmentVariable("Path",
4
+ [Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::Machine) + ";C:\var\lib\rancher\rke2\bin;c:\usr\local\bin",
5
+ [EnvironmentVariableTarget]::Machine)
@@ -11,12 +11,6 @@ Set-Content -Path !!CONFIG_PATH!! -Value @"
11
11
  Write-Host "Installing RKE2 as an agent..."
12
12
  ./install.ps1 !!ENV!!
13
13
 
14
- Write-Host "Creating RKE2 environment variables..."
15
- $env:PATH+=";C:\var\lib\rancher\rke2\bin;c:\usr\local\bin"
16
- [Environment]::SetEnvironmentVariable("Path",
17
- [Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::Machine) + ";C:\var\lib\rancher\rke2\bin;c:\usr\local\bin",
18
- [EnvironmentVariableTarget]::Machine)
19
-
20
14
  Write-Host "Open ports for RKE2 and Calico in firewall..."
21
15
  netsh advfirewall firewall add rule name= "RKE2-kubelet" dir=in action=allow protocol=TCP localport=10250
22
16
  netsh advfirewall firewall add rule name= "RKE2-agent" dir=in action=allow protocol=TCP localport=4789
@@ -55,7 +55,12 @@ module VagrantPlugins
55
55
 
56
56
  # Defaults to true
57
57
  # @return [Boolean]
58
- attr_accessor :install_kubectl
58
+ attr_accessor :install_path
59
+
60
+ # Defaults to false
61
+ # @return [Boolean]
62
+ attr_accessor :skip_start
63
+
59
64
 
60
65
  def initialize
61
66
  @config = UNSET_VALUE
@@ -67,7 +72,8 @@ module VagrantPlugins
67
72
  @env_owner = UNSET_VALUE
68
73
  @env_path = UNSET_VALUE
69
74
  @installer_url = UNSET_VALUE
70
- @install_kubectl = UNSET_VALUE
75
+ @install_path = UNSET_VALUE
76
+ @skip_start = UNSET_VALUE
71
77
  end
72
78
 
73
79
  def finalize!
@@ -80,7 +86,8 @@ module VagrantPlugins
80
86
  @env_owner = DEFAULT_ENV_OWNER if @env_owner == UNSET_VALUE
81
87
  @env_path = DEFAULT_ENV_PATH if @env_path == UNSET_VALUE
82
88
  @installer_url = DEFAULT_INSTALLER_URL_LINUX if @installer_url == UNSET_VALUE
83
- @install_kubectl = true if @install_kubectl == UNSET_VALUE
89
+ @install_path = true if @install_path == UNSET_VALUE
90
+ @skip_start = false if @skip_start == UNSET_VALUE
84
91
  end
85
92
 
86
93
  def validate(machine)
@@ -65,28 +65,6 @@ module VagrantPlugins
65
65
  @machine.communicate.sudo("chmod +x #{prv_file} && #{prv_file}", :error_key => :ssh_bad_exit_status_muted) do |type, line|
66
66
  @machine.ui.detail line, :color => :yellow
67
67
  end
68
- # outputs, handler = build_outputs
69
- # begin
70
- # @machine.communicate.sudo("chmod +x #{prv_file} && #{prv_file}", error_key: :ssh_bad_exit_status_muted, &handler)
71
- # ensure
72
- # outputs.values.map(&:close)
73
- # end
74
-
75
- if config.install_kubectl
76
- kube_file = "/vagrant/kubectl-install.sh"
77
- kube_text = <<~EOF
78
- curl -L "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" -o /usr/local/bin/kubectl
79
- chmod +x /usr/local/bin/kubectl
80
- EOF
81
- file_upload("kubectl-install.sh", kube_file, kube_text)
82
- @machine.ui.info "Invoking: #{kube_file}"
83
- outputs, handler = build_outputs
84
- begin
85
- @machine.communicate.sudo("chmod +x #{kube_file} && #{kube_file}", &handler)
86
- ensure
87
- outputs.values.map(&:close)
88
- end
89
- end
90
68
 
91
69
  begin
92
70
  exe = "rke2"
@@ -110,8 +88,21 @@ module VagrantPlugins
110
88
  end
111
89
  else
112
90
  @machine.communicate.sudo("systemctl enable rke2-server.service")
113
- @machine.communicate.sudo("systemctl start rke2-server.service") do |type, line|
114
- @machine.ui.detail line, :color => :yellow
91
+ if !config.skip_start
92
+ @machine.communicate.sudo("systemctl start rke2-server.service") do |type, line|
93
+ @machine.ui.detail line, :color => :yellow
94
+ end
95
+ end
96
+ end
97
+
98
+ if config.install_path
99
+ @machine.ui.info "Adding RKE2 to PATH and KUBECONFIG"
100
+ outputs, handler = build_outputs
101
+ begin
102
+ @machine.communicate.sudo("echo 'export KUBECONFIG=/etc/rancher/rke2/rke2.yaml PATH=$PATH:/var/lib/rancher/rke2/bin' >> /home/vagrant/.bashrc", &handler)
103
+ @machine.communicate.sudo("echo 'export KUBECONFIG=/etc/rancher/rke2/rke2.yaml PATH=$PATH:/var/lib/rancher/rke2/bin' >> /root/.bashrc", &handler)
104
+ ensure
105
+ outputs.values.map(&:close)
115
106
  end
116
107
  end
117
108
  end
@@ -157,15 +148,26 @@ module VagrantPlugins
157
148
  @machine.ui.detail line.chomp, :color => :yellow
158
149
  end
159
150
 
151
+ if config.install_path
152
+ setupPath = "setup-path.ps1"
153
+ @machine.ui.info "Invoking: #{setupPath}"
154
+ command = File.read(scriptDir + setupPath)
155
+ @machine.communicate.execute(command, {shell: :powershell, elevated: true}) do |type, line|
156
+ @machine.ui.detail line.chomp, :color => :yellow
157
+ end
158
+ end
159
+
160
160
  @machine.ui.info "Checking RKE2 version:"
161
161
  @machine.communicate.test("Get-Command rke2", {shell: :powershell})
162
- @machine.communicate.execute("rke2 --version", {shell: :powershell}) do |type, line|
162
+ @machine.communicate.execute('C:\usr\local\bin\rke2.exe --version', {shell: :powershell}) do |type, line|
163
163
  @machine.ui.detail line, :color => :yellow
164
164
  end
165
165
 
166
166
  @machine.ui.info "Starting RKE2 agent:"
167
- @machine.communicate.execute("rke2.exe agent service --add", {shell: :powershell, elevated: true} )
168
- @machine.communicate.execute("Start-Service -Name 'rke2'", {shell: :powershell, elevated: true} )
167
+ @machine.communicate.execute('C:\usr\local\bin\rke2.exe agent service --add', {shell: :powershell, elevated: true} )
168
+ if !config.skip_start
169
+ @machine.communicate.execute("Start-Service -Name 'rke2'", {shell: :powershell, elevated: true} )
170
+ end
169
171
 
170
172
  end
171
173
 
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Rke2
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-rke2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derek Nola
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-18 00:00:00.000000000 Z
11
+ date: 2022-03-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Manage RKE2 installations on Vagrant guests
14
14
  email:
@@ -31,6 +31,7 @@ files:
31
31
  - lib/vagrant-rke2/cap/linux/curl_installed.rb
32
32
  - lib/vagrant-rke2/cap/linux/rke2_installed.rb
33
33
  - lib/vagrant-rke2/cap/windows/scripts/install-containers-feature.ps1
34
+ - lib/vagrant-rke2/cap/windows/scripts/setup-path.ps1
34
35
  - lib/vagrant-rke2/cap/windows/scripts/setup-rke2.ps1
35
36
  - lib/vagrant-rke2/config.rb
36
37
  - lib/vagrant-rke2/plugin.rb
@@ -58,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
59
  - !ruby/object:Gem::Version
59
60
  version: '0'
60
61
  requirements: []
61
- rubygems_version: 3.1.2
62
+ rubygems_version: 3.2.5
62
63
  signing_key:
63
64
  specification_version: 4
64
65
  summary: Manage RKE2 installations on Vagrant guests