Skip to content

Commit

Permalink
Merge pull request #6 from dereknola/skip_start
Browse files Browse the repository at this point in the history
Add skip_start option
  • Loading branch information
dereknola authored Nov 9, 2022
2 parents 2397b74 + 0334a17 commit cde7e72
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 36 deletions.
10 changes: 3 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,13 @@ jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
ruby:
- 2.7.0

steps:
- uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
ruby-version: "3.0.2"
- name: Setup bundle
run: bundle update && bundle install
- name: Run the default task
run: bundle exec rake
2 changes: 0 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ end

group :plugins do
gemspec
# gem "vagrant-libvirt"
# gem "vagrant-reload"
# gem "vagrant-timezone"
# gem "vagrant-vmware-desktop"
end
37 changes: 19 additions & 18 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -28,63 +28,64 @@ GIT
PATH
remote: .
specs:
vagrant-k3s (0.1.4.pre.dev)
vagrant-k3s (0.1.5)

GEM
remote: https://rubygems.org/
specs:
bcrypt_pbkdf (1.1.0)
builder (3.2.4)
childprocess (4.1.0)
concurrent-ruby (1.1.9)
diff-lcs (1.4.4)
concurrent-ruby (1.1.10)
diff-lcs (1.5.0)
ed25519 (1.2.4)
erubi (1.10.0)
excon (0.88.0)
ffi (1.15.4)
erubi (1.11.0)
excon (0.94.0)
ffi (1.15.5)
gssapi (1.3.1)
ffi (>= 1.0.1)
gyoku (1.3.1)
gyoku (1.4.0)
builder (>= 2.1.2)
rexml (~> 3.0)
hashicorp-checkpoint (0.1.5)
httpclient (2.8.3)
i18n (1.8.11)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
listen (3.7.0)
listen (3.7.1)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
little-plugger (1.1.4)
log4r (1.1.10)
logging (2.3.0)
logging (2.3.1)
little-plugger (~> 1.1)
multi_json (~> 1.14)
mime-types (3.4.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2021.1115)
mime-types-data (3.2022.0105)
multi_json (1.15.0)
net-scp (3.0.0)
net-ssh (>= 2.6.5, < 7.0.0)
net-ssh (>= 2.6.5)
net-sftp (3.0.0)
net-ssh (>= 5.0.0, < 7.0.0)
net-ssh (6.1.0)
nori (2.6.0)
rake (13.0.6)
rb-fsevent (0.11.0)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
rb-kqueue (0.2.7)
rb-kqueue (0.2.8)
ffi (>= 0.5.0)
rexml (3.2.5)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
rspec-mocks (~> 3.10.0)
rspec-core (3.10.1)
rspec-core (3.10.2)
rspec-support (~> 3.10.0)
rspec-expectations (3.10.1)
rspec-expectations (3.10.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-mocks (3.10.2)
rspec-mocks (3.10.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-support (3.10.3)
Expand Down Expand Up @@ -124,4 +125,4 @@ DEPENDENCIES
vagrant-k3s!

BUNDLED WITH
2.2.27
2.3.14
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,25 @@ Vagrant.configure("2") do |config|
# k3s.args = '--config=/some/other/config.yaml'
# default => `/etc/rancher/k3s/config.yaml`
k3s.config_path = '/etc/rancher/k3s/config.yaml'

# skip_start: install but don't start K3s
# type => Boolean
# default => false
k3s.skip_start = true
end
end

```
## Development

See https://www.vagrantup.com/docs/plugins/development-basics
- `gem build`
- `VAGRANT_CWD=./test/ubuntu bundle exec vagrant up`

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/dweomer/vagrant-k3s. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/dweomer/vagrant-k3s/blob/master/CODE_OF_CONDUCT.md).
Bug reports and pull requests are welcome on GitHub at https://github.com/k3s-io/vagrant-k3s.

## Code of Conduct

Everyone interacting in the Vagrant::K3s project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/dweomer/vagrant-k3s/blob/master/CODE_OF_CONDUCT.md).
This project is intended to be a safe, welcoming space for collaboration. Everyone interacting in the vagrant-k3s projects codebase is expected to adhere to the [code of conduct](CODE_OF_CONDUCT.md).
6 changes: 6 additions & 0 deletions lib/vagrant-k3s/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ class Config < Vagrant.plugin(2, :config)
# @return [String]
attr_accessor :installer_url

# Defaults to false
# @return [Boolean]
attr_accessor :skip_start

# # INSTALL_K3S_BIN_DIR
# # @return [String]
# attr_accessor :install_bin_dir
Expand Down Expand Up @@ -104,6 +108,7 @@ def initialize
@env_owner = UNSET_VALUE
@env_path = UNSET_VALUE
@installer_url = UNSET_VALUE
@skip_start = UNSET_VALUE
end

def finalize!
Expand All @@ -117,6 +122,7 @@ def finalize!
@env_owner = DEFAULT_ENV_OWNER if @env_owner == UNSET_VALUE
@env_path = DEFAULT_ENV_PATH if @env_path == UNSET_VALUE
@installer_url = DEFAULT_INSTALLER_URL if @installer_url == UNSET_VALUE
@skip_start = false if @skip_start == UNSET_VALUE

if @args && args_valid?
@args = @args.is_a?(Array) ? @args.map { |a| a.to_s } : @args.to_s
Expand Down
7 changes: 6 additions & 1 deletion lib/vagrant-k3s/provisioner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ def provision
end
file_upload "k3s-install.env", env_file, env_text

skip_env = ""
if config.skip_start
skip_env = "INSTALL_K3S_SKIP_ENABLE=true"
end

prv_file = "/vagrant/k3s-provisioner.sh"
prv_text = <<~EOF
#/usr/bin/env bash
Expand All @@ -62,7 +67,7 @@ def provision
set -o allexport
source #{config.env_path}
set +o allexport
curl -fsL '#{config.installer_url}' | sh -s - #{args}
curl -fsL '#{config.installer_url}' | #{skip_env} sh -s - #{args}
EOF
file_upload("k3s-install.sh", prv_file, prv_text)
@machine.ui.info "Invoking: #{prv_file}"
Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant-k3s/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module VagrantPlugins
module K3s
VERSION = '0.1.4.dev.1'
VERSION = '0.1.5'
end
end
3 changes: 2 additions & 1 deletion test/focal/Vagrantfile → test/ubuntu/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ENV['VAGRANT_DEFAULT_PROVIDER'] ||= 'virtualbox'
Vagrant.configure("2") do |config|
# the vm.define mullet: business up front, party in the back (below)
config.vm.define 'vagrant-k3s-test', primary: true do |node|
node.vm.box = 'ubuntu/focal64'
node.vm.box = 'generic/ubuntu2004'
node.vm.hostname = 'vagrant'
node.vm.provision :k3s, run: "once" do |k3s|
k3s.args = %w[server]
Expand All @@ -22,6 +22,7 @@ Vagrant.configure("2") do |config|
:disable => %w[local-storage metrics-server servicelb traefik],
'disable-network-policy' => true,
}
k3s.skip_start = true
end
end

Expand Down
8 changes: 4 additions & 4 deletions vagrant-k3s.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ Gem::Specification.new do |spec|
spec.name = 'vagrant-k3s'
spec.version = VagrantPlugins::K3s::VERSION
spec.platform = Gem::Platform::RUBY
spec.authors = ['Jacob Blain Christen']
spec.email = ['[email protected]']
spec.authors = ['Derek Nola', 'Jacob Blain Christen']
spec.email = ['[email protected]', '[email protected]']

spec.license = 'Apache 2.0'
spec.license = 'Apache-2.0'

spec.summary = 'Manage k3s installations on Vagrant guests.'
spec.description = spec.summary
spec.homepage = 'https://github.com/dweomer/vagrant-k3s'
spec.homepage = 'https://github.com/k3s-io/vagrant-k3s'

spec.metadata['homepage_uri'] = spec.homepage
spec.metadata['source_code_uri'] = spec.homepage
Expand Down

0 comments on commit cde7e72

Please sign in to comment.