vagrant-vmck 0.2.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.drone.yml +3 -14
- data/.github/workflows/gempush.yml +29 -0
- data/.gitignore +0 -2
- data/Dockerfile +3 -1
- data/Gemfile +1 -0
- data/Readme.md +21 -4
- data/examples/box/.gitignore +1 -0
- data/examples/box/Vagrantfile +28 -0
- data/examples/install.sh +3 -0
- data/lib/vagrant-vmck/action/create.rb +16 -9
- data/lib/vagrant-vmck/client.rb +3 -1
- data/lib/vagrant-vmck/config.rb +3 -0
- data/lib/vagrant-vmck/plugin.rb +23 -1
- data/lib/vagrant-vmck/version.rb +1 -1
- data/submission/Vagrantfile +13 -0
- data/submission/launch.sh +31 -0
- data/vagrant-vmck.gemspec +1 -1
- metadata +10 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 82d621045e2fc2b556bcacaa6fc5a55aca78109566f9ffaeedb27ec82640d3c3
|
4
|
+
data.tar.gz: e1a349611a010f24749e6e656f4f354c51ed0689135f4743171a4665078612f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac952fc7c5845af3bf8a2961e7e561db9fec0fdb1ec58dc2928a26695c42da8dc7d51e799dd95f01ce896966e5bfe72316f0e6a9358c1431a243a922ebabdcd2
|
7
|
+
data.tar.gz: 143dc9e194e9ca8d4c4effe52d2d062af97a1bfbf943fa9bbd4a6c4eb78cf3f8f8df2f08f3655fee58e65008826bed23473d69d7eb8cacd195c231bbfb0b1a3f
|
data/.drone.yml
CHANGED
@@ -71,6 +71,9 @@ steps:
|
|
71
71
|
when:
|
72
72
|
event:
|
73
73
|
- push
|
74
|
+
branch:
|
75
|
+
exclude:
|
76
|
+
- dependabot/*
|
74
77
|
|
75
78
|
- name: docker push autotag + latest
|
76
79
|
image: plugins/docker
|
@@ -81,17 +84,3 @@ steps:
|
|
81
84
|
from_secret: docker_username
|
82
85
|
password:
|
83
86
|
from_secret: docker_password
|
84
|
-
|
85
|
-
---
|
86
|
-
kind: secret
|
87
|
-
name: docker_username
|
88
|
-
get:
|
89
|
-
path: liquid/ci/drone.docker
|
90
|
-
name: username
|
91
|
-
|
92
|
-
---
|
93
|
-
kind: secret
|
94
|
-
name: docker_password
|
95
|
-
get:
|
96
|
-
path: liquid/ci/drone.docker
|
97
|
-
name: password
|
@@ -0,0 +1,29 @@
|
|
1
|
+
name: Ruby Gem
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
tags:
|
6
|
+
- v*
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
build:
|
10
|
+
name: Build + Publish
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@master
|
15
|
+
- name: Set up Ruby 2.6
|
16
|
+
uses: actions/setup-ruby@v1
|
17
|
+
with:
|
18
|
+
version: 2.6.x
|
19
|
+
|
20
|
+
- name: Publish to RubyGems
|
21
|
+
run: |
|
22
|
+
mkdir -p $HOME/.gem
|
23
|
+
touch $HOME/.gem/credentials
|
24
|
+
chmod 0600 $HOME/.gem/credentials
|
25
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
26
|
+
gem build *.gemspec
|
27
|
+
gem push *.gem
|
28
|
+
env:
|
29
|
+
GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
|
data/.gitignore
CHANGED
data/Dockerfile
CHANGED
@@ -7,7 +7,9 @@ ADD . .
|
|
7
7
|
|
8
8
|
RUN set -e \
|
9
9
|
&& apt-get update -q \
|
10
|
-
&& apt-get install -yq wget git procps kmod rsync ruby-dev \
|
10
|
+
&& apt-get install -yq wget git procps kmod rsync ruby-dev curl \
|
11
|
+
&& wget https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 -O /usr/bin/jq \
|
12
|
+
&& chmod +x /usr/bin/jq \
|
11
13
|
&& wget https://releases.hashicorp.com/vagrant/2.2.4/vagrant_2.2.4_x86_64.deb \
|
12
14
|
&& dpkg -i vagrant_2.2.4_x86_64.deb \
|
13
15
|
&& rm vagrant_2.2.4_x86_64.deb \
|
data/Gemfile
CHANGED
data/Readme.md
CHANGED
@@ -28,13 +28,30 @@ The vmck provider is also packaged as a docker image:
|
|
28
28
|
./examples/docker.sh --dev --env VMCK_URL=http://10.66.60.1:9995
|
29
29
|
```
|
30
30
|
|
31
|
+
|
32
|
+
## Development
|
33
|
+
|
34
|
+
You can test the code using `bundle exec`:
|
35
|
+
|
36
|
+
```shell
|
37
|
+
export VMCK_URL=http://localhost:10000
|
38
|
+
export VMCK_NAME="example"
|
39
|
+
export VAGRANT_CWD=examples/box
|
40
|
+
|
41
|
+
bundle install
|
42
|
+
bundle exec vagrant up
|
43
|
+
```
|
44
|
+
|
45
|
+
|
31
46
|
## Release
|
47
|
+
|
32
48
|
1. Update `lib/vagrant-vmck/version.rb` and commit
|
33
49
|
2. `git tag v1.2.3; git push --tags`
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
50
|
+
|
51
|
+
The [gempush workflow](.github/workflows/gempush.yml) takes care of the rest,
|
52
|
+
see it work away in the [actions
|
53
|
+
tab](https://github.com/vmck/vagrant-vmck/actions).
|
54
|
+
|
38
55
|
|
39
56
|
## License
|
40
57
|
|
@@ -0,0 +1 @@
|
|
1
|
+
/.env
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
# vi: set ft=ruby :
|
3
|
+
|
4
|
+
Vagrant.configure("2") do |config|
|
5
|
+
if Vagrant.has_plugin?("vagrant-env")
|
6
|
+
config.env.enable
|
7
|
+
end
|
8
|
+
|
9
|
+
config.vm.box = "base"
|
10
|
+
config.nfs.functional = false
|
11
|
+
config.smb.functional = false
|
12
|
+
|
13
|
+
config.vm.provision 'hello', type: 'shell', inline: "
|
14
|
+
set -x
|
15
|
+
echo hello world
|
16
|
+
"
|
17
|
+
|
18
|
+
config.vm.provider :vmck do |vmck|
|
19
|
+
vmck.image_path = 'imgbuild-master.qcow2.tar.gz'
|
20
|
+
vmck.vmck_url = ENV['VMCK_URL']
|
21
|
+
vmck.memory = 512
|
22
|
+
vmck.cpus = 1
|
23
|
+
vmck.restrict_network = false
|
24
|
+
vmck.storage = ENV['VMCK_STORAGE']
|
25
|
+
vmck.name = ENV['VMCK_NAME']
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
data/examples/install.sh
ADDED
@@ -14,15 +14,22 @@ module VagrantPlugins
|
|
14
14
|
def call(env)
|
15
15
|
client = env[:vmck]
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
17
|
+
if ENV['VMCK_JOB_ID'].nil?
|
18
|
+
env[:ui].info("Vmck starting job ...")
|
19
|
+
options = {
|
20
|
+
'cpus': env[:machine].provider_config.cpus,
|
21
|
+
'memory': env[:machine].provider_config.memory,
|
22
|
+
'image_path': env[:machine].provider_config.image_path,
|
23
|
+
'storage': env[:machine].provider_config.storage,
|
24
|
+
'name': env[:machine].provider_config.name,
|
25
|
+
'restrict_network': env[:machine].provider_config.restrict_network,
|
26
|
+
}
|
27
|
+
id = client.create(options)['id'].to_s
|
28
|
+
else
|
29
|
+
id = ENV['VMCK_JOB_ID']
|
30
|
+
env[:ui].info("Vmck using existing job #{id}")
|
31
|
+
end
|
32
|
+
|
26
33
|
env[:machine].id = id
|
27
34
|
|
28
35
|
env[:ui].info("Vmck waiting for job #{id} to be ready ...")
|
data/lib/vagrant-vmck/client.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'log4r'
|
1
2
|
require 'faraday'
|
2
3
|
require 'json'
|
3
4
|
|
@@ -6,7 +7,7 @@ module VagrantPlugins
|
|
6
7
|
class Client
|
7
8
|
|
8
9
|
def initialize(url)
|
9
|
-
@logger = Log4r::Logger.new(
|
10
|
+
@logger = Log4r::Logger.new("vagrant_vmck::client")
|
10
11
|
@client = Faraday.new({ :url => url })
|
11
12
|
end
|
12
13
|
|
@@ -17,6 +18,7 @@ module VagrantPlugins
|
|
17
18
|
req.url(path)
|
18
19
|
if data
|
19
20
|
req.headers['Content-Type'] = 'application/json'
|
21
|
+
@logger.info "Request body: #{data}"
|
20
22
|
req.body = JSON.generate(data)
|
21
23
|
end
|
22
24
|
end
|
data/lib/vagrant-vmck/config.rb
CHANGED
@@ -8,6 +8,7 @@ module VagrantPlugins
|
|
8
8
|
attr_accessor :image_path
|
9
9
|
attr_accessor :storage
|
10
10
|
attr_accessor :name
|
11
|
+
attr_accessor :restrict_network
|
11
12
|
|
12
13
|
def initialize
|
13
14
|
@vmck_url = UNSET_VALUE
|
@@ -17,6 +18,7 @@ module VagrantPlugins
|
|
17
18
|
@image_path = UNSET_VALUE
|
18
19
|
@storage = UNSET_VALUE
|
19
20
|
@name = UNSET_VALUE
|
21
|
+
@restrict_network = UNSET_VALUE
|
20
22
|
end
|
21
23
|
|
22
24
|
def finalize!
|
@@ -27,6 +29,7 @@ module VagrantPlugins
|
|
27
29
|
@image_path = 'imgbuild-master.qcow2.tar.gz' if @image_path == UNSET_VALUE
|
28
30
|
@storage = nil if @storage == UNSET_VALUE
|
29
31
|
@name = 'default' if @name == UNSET_VALUE
|
32
|
+
@restrict_network = false if @restrict_network == UNSET_VALUE
|
30
33
|
end
|
31
34
|
|
32
35
|
end
|
data/lib/vagrant-vmck/plugin.rb
CHANGED
@@ -9,10 +9,32 @@ module VagrantPlugins
|
|
9
9
|
end
|
10
10
|
|
11
11
|
provider :vmck do
|
12
|
+
setup_logging
|
13
|
+
|
12
14
|
require_relative 'provider'
|
13
15
|
Provider
|
14
16
|
end
|
15
|
-
end
|
16
17
|
|
18
|
+
def self.setup_logging
|
19
|
+
require "log4r"
|
20
|
+
|
21
|
+
level = nil
|
22
|
+
begin
|
23
|
+
level = Log4r.const_get(ENV["VAGRANT_LOG"].upcase)
|
24
|
+
rescue NameError
|
25
|
+
level = nil
|
26
|
+
end
|
27
|
+
|
28
|
+
level = nil if !level.is_a?(Integer)
|
29
|
+
|
30
|
+
if level
|
31
|
+
logger = Log4r::Logger.new("vagrant_vmck")
|
32
|
+
logger.outputters = Log4r::Outputter.stderr
|
33
|
+
logger.level = level
|
34
|
+
logger = nil
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
17
39
|
end
|
18
40
|
end
|
data/lib/vagrant-vmck/version.rb
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/bin/bash -ex
|
2
|
+
|
3
|
+
cd "$( dirname "${BASH_SOURCE[0]}" )"
|
4
|
+
|
5
|
+
trap "vagrant destroy -f" EXIT
|
6
|
+
|
7
|
+
curl "${VMCK_ARCHIVE_URL}" -o archive.zip
|
8
|
+
curl "${VMCK_SCRIPT_URL}" -o script.sh
|
9
|
+
curl "${VMCK_ARTIFACT_URL}" -o artifact.zip
|
10
|
+
|
11
|
+
chmod +x script.sh
|
12
|
+
|
13
|
+
vagrant up
|
14
|
+
(
|
15
|
+
set +e
|
16
|
+
vagrant ssh -- 'cd /vagrant; ./script.sh' &> result.out
|
17
|
+
echo $? > result.exit_code
|
18
|
+
)
|
19
|
+
|
20
|
+
exit_code=$(cat result.exit_code)
|
21
|
+
base64 result.out > stdout.tmp
|
22
|
+
cat stdout.tmp | tr -d '\n' > stdout
|
23
|
+
|
24
|
+
jq -n \
|
25
|
+
--rawfile out stdout \
|
26
|
+
--arg code $exit_code \
|
27
|
+
'{stdout: $out, exit_code: $code,}' > out.json
|
28
|
+
|
29
|
+
curl -X POST "${VMCK_CALLBACK_URL}" -d @out.json \
|
30
|
+
--header "Content-Type: application/json" \
|
31
|
+
--retry 20 --retry-connrefused
|
data/vagrant-vmck.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-vmck
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Morega
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '13.0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '13.0'
|
83
83
|
description: Enables Vagrant to use Vmck jobs.
|
84
84
|
email:
|
85
85
|
- alex@grep.ro
|
@@ -88,13 +88,16 @@ extensions: []
|
|
88
88
|
extra_rdoc_files: []
|
89
89
|
files:
|
90
90
|
- ".drone.yml"
|
91
|
+
- ".github/workflows/gempush.yml"
|
91
92
|
- ".gitignore"
|
92
93
|
- Dockerfile
|
93
94
|
- Gemfile
|
94
95
|
- LICENSE.txt
|
95
96
|
- Readme.md
|
97
|
+
- examples/box/.gitignore
|
96
98
|
- examples/box/Vagrantfile
|
97
99
|
- examples/docker.sh
|
100
|
+
- examples/install.sh
|
98
101
|
- lib/vagrant-vmck.rb
|
99
102
|
- lib/vagrant-vmck/action.rb
|
100
103
|
- lib/vagrant-vmck/action/connect_vmck.rb
|
@@ -107,6 +110,8 @@ files:
|
|
107
110
|
- lib/vagrant-vmck/provider.rb
|
108
111
|
- lib/vagrant-vmck/version.rb
|
109
112
|
- run-test.sh
|
113
|
+
- submission/Vagrantfile
|
114
|
+
- submission/launch.sh
|
110
115
|
- vagrant-vmck.gemspec
|
111
116
|
homepage: https://github.com/mgax/vagrant-vmck
|
112
117
|
licenses:
|
@@ -127,8 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
132
|
- !ruby/object:Gem::Version
|
128
133
|
version: '0'
|
129
134
|
requirements: []
|
130
|
-
|
131
|
-
rubygems_version: 2.5.2.3
|
135
|
+
rubygems_version: 3.0.3
|
132
136
|
signing_key:
|
133
137
|
specification_version: 4
|
134
138
|
summary: Vagrant provider plugin for Vmck.
|