vagrant-local 0.0.1 → 0.0.3
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 +4 -4
- data/CHANGELOG.md +15 -0
- data/lib/vagrant-local/action/import.rb +26 -0
- data/lib/vagrant-local/action/shutdown.rb +3 -4
- data/lib/vagrant-local/action.rb +3 -0
- data/lib/vagrant-local/config.rb +3 -27
- data/lib/vagrant-local/driver.rb +22 -13
- data/lib/vagrant-local/plugin.rb +41 -0
- data/lib/vagrant-local/provider.rb +1 -1
- data/lib/vagrant-local/version.rb +1 -1
- data/locales/en.yml +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a89d76235d6a942e97650006ad5cb0b3d63d49f3c49b9e7399436f40bb64b2a5
|
4
|
+
data.tar.gz: fe62addcdcd2d655916d7e6b69aac20f86a519c88b22e644c2bef47afd69af45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d18df1d17d038cb24323454ea056398b1608a41292c086e2ab6c9a1b78a2928e25cf4baccc4f016d3d0e6d98eb31f78fe3809c464adb0169871c87b8f395e7b
|
7
|
+
data.tar.gz: f0adbd5ebf7110421c48e10a6417cb447f2bb8acc8d77ffc71a9e3b1e7933e8d39a7da77d23fea2255f0bab2767a2846b1bc9db158a3c6ff52b743a1b121ab98
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,20 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [0.0.3](https://github.com/STARTcloud/vagrant-local/compare/v0.0.2...v0.0.3) (2024-01-17)
|
4
|
+
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
* remove pty ([ca5924c](https://github.com/STARTcloud/vagrant-local/commit/ca5924ce22b97c87f15d361d409afe42d24f1e4b))
|
9
|
+
|
10
|
+
## [0.0.2](https://github.com/STARTcloud/vagrant-local/compare/v0.0.1...v0.0.2) (2024-01-17)
|
11
|
+
|
12
|
+
|
13
|
+
### Bug Fixes
|
14
|
+
|
15
|
+
* box format auto-detect ([0d205f2](https://github.com/STARTcloud/vagrant-local/commit/0d205f2b2c0517669d1057cc1abc11f7f650cb9e))
|
16
|
+
* call playbook instead of invidual plays ([8ebab01](https://github.com/STARTcloud/vagrant-local/commit/8ebab01374e7dc9b03a985ff862654a59add3afe))
|
17
|
+
|
3
18
|
## [0.0.1](https://github.com/STARTcloud/vagrant-local/compare/v1.0.1...v0.0.1) (2024-01-15)
|
4
19
|
|
5
20
|
|
@@ -18,7 +18,33 @@ module VagrantPlugins
|
|
18
18
|
@app = app
|
19
19
|
end
|
20
20
|
|
21
|
+
def validate_uuid_format(uuid)
|
22
|
+
uuid_regex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/
|
23
|
+
true if uuid_regex.match?(uuid.to_s.downcase)
|
24
|
+
end
|
25
|
+
|
21
26
|
def call(env)
|
27
|
+
@machine = env[:machine]
|
28
|
+
@executor = Executor::Exec.new
|
29
|
+
image = @machine.config.vm.box
|
30
|
+
datadir = @machine.data_dir
|
31
|
+
@driver = @machine.provider.driver
|
32
|
+
ui = env[:ui]
|
33
|
+
ui.info(I18n.t('vagrant_local.meeting'))
|
34
|
+
ui.info(I18n.t('vagrant_local.datadir'))
|
35
|
+
ui.info(" #{datadir}")
|
36
|
+
ui.info(I18n.t('vagrant_local.detecting_box'))
|
37
|
+
|
38
|
+
# Support zss maybe zst? Same thing? format only for now, use other images and convert later
|
39
|
+
box_format = env[:machine].box.metadata['format'] unless env[:machine].box.nil?
|
40
|
+
|
41
|
+
# Insert Future Code to try to convert existing box
|
42
|
+
ui.info(I18n.t('vagrant_local.detected_format')) if %w[ovf ova].include?(box_format)
|
43
|
+
|
44
|
+
## No Local box template exists, Lets use Vagrant HandleBox to download the Box template
|
45
|
+
ui.info(I18n.t('vagrant_local.vagrant_cloud_box_detected'))
|
46
|
+
ui.info(" #{image}")
|
47
|
+
ui.clear_line
|
22
48
|
@app.call(env)
|
23
49
|
end
|
24
50
|
end
|
@@ -31,10 +31,9 @@ module VagrantPlugins
|
|
31
31
|
end
|
32
32
|
env[:metrics]['instance_ssh_time'] = Util::Timer.time do
|
33
33
|
300.times do
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
break unless state_id == :running
|
34
|
+
ui.info(I18n.t('vagrant_local.graceful_shutdown_complete')) unless @driver.state == :running
|
35
|
+
sleep 1 if @driver.state == :running
|
36
|
+
break unless @driver.state == :running
|
38
37
|
break if env[:interrupted]
|
39
38
|
end
|
40
39
|
end
|
data/lib/vagrant-local/action.rb
CHANGED
data/lib/vagrant-local/config.rb
CHANGED
@@ -6,34 +6,16 @@ module VagrantPlugins
|
|
6
6
|
module ProviderLocal
|
7
7
|
# This is used define the variables for the project
|
8
8
|
class Config < Vagrant.plugin('2', :config)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
# rubocop:enable Layout/LineLength
|
9
|
+
attr_accessor :brand, :boxshortname, :kernel, :debug, :boot, :vagrant_user, :vagrant_user_private_key_path, :clean_shutdown_time, :vagrant_user_pass, :vm_type, :partition_id, :sshport,
|
10
|
+
:rdpport, :box, :vagrant_cloud_creator
|
13
11
|
|
14
12
|
def initialize
|
15
13
|
super
|
16
|
-
@brand = '
|
17
|
-
@additional_disks = UNSET_VALUE
|
18
|
-
@autoboot = true
|
19
|
-
@post_provision_boot = false
|
14
|
+
@brand = 'aws'
|
20
15
|
@kernel = nil
|
21
16
|
@boxshortname = UNSET_VALUE
|
22
|
-
@cdroms = nil
|
23
|
-
@shared_dir = nil
|
24
|
-
@os_type = 'generic'
|
25
|
-
@debug_boot = nil
|
26
17
|
@debug = nil
|
27
|
-
@consoleport = nil
|
28
|
-
@consolehost = '0.0.0.0'
|
29
|
-
@console_onboot = 'false'
|
30
|
-
@console = 'webvnc'
|
31
|
-
@memory = '2G'
|
32
|
-
@diskif = 'virtio-blk'
|
33
|
-
@netif = 'virtio-net-viona'
|
34
|
-
@cpus = 1
|
35
18
|
@boot = UNSET_VALUE
|
36
|
-
@setup_wait = 90
|
37
19
|
@box = UNSET_VALUE
|
38
20
|
@clean_shutdown_time = 300
|
39
21
|
@vmtype = 'production'
|
@@ -43,12 +25,6 @@ module VagrantPlugins
|
|
43
25
|
@vagrant_user = 'vagrant'
|
44
26
|
@vagrant_user_pass = 'vagrant'
|
45
27
|
@vagrant_user_private_key_path = './id_rsa'
|
46
|
-
@xhci_enabled = 'off'
|
47
|
-
@override = false
|
48
|
-
@login_wait = 5
|
49
|
-
@private_network = nil
|
50
|
-
@vm_type = 'production'
|
51
|
-
@setup_method = nil
|
52
28
|
end
|
53
29
|
end
|
54
30
|
end
|
data/lib/vagrant-local/driver.rb
CHANGED
@@ -8,7 +8,6 @@ require 'ruby_expect'
|
|
8
8
|
require 'netaddr'
|
9
9
|
require 'ipaddr'
|
10
10
|
require 'vagrant/util/numeric'
|
11
|
-
require 'pty'
|
12
11
|
require 'expect'
|
13
12
|
require 'vagrant'
|
14
13
|
require 'resolv'
|
@@ -37,8 +36,17 @@ module VagrantPlugins
|
|
37
36
|
end
|
38
37
|
end
|
39
38
|
|
40
|
-
def state
|
41
|
-
|
39
|
+
def state
|
40
|
+
data = [{
|
41
|
+
'name' => nil,
|
42
|
+
'ec2_id' => nil,
|
43
|
+
'state' => 'not_created',
|
44
|
+
'public_ip' => nil
|
45
|
+
}]
|
46
|
+
vmstate_file = "#{@machine.name}.vmstate"
|
47
|
+
File.write(vmstate_file, data.to_yaml) unless File.exist?(vmstate_file)
|
48
|
+
|
49
|
+
vm_data = YAML.load_file(vmstate_file)
|
42
50
|
return :not_created unless vm_data.is_a?(Array) && !vm_data.empty? && vm_data.first.is_a?(Hash)
|
43
51
|
|
44
52
|
vm_state = vm_data.first['state']
|
@@ -59,8 +67,8 @@ module VagrantPlugins
|
|
59
67
|
|
60
68
|
## Begin installation
|
61
69
|
def install(_uii)
|
62
|
-
config = @machine.config.vm.provisioners[
|
63
|
-
command = "#{@pfexec} ansible-playbook ./providers/ansible/
|
70
|
+
config = @machine.config.vm.provisioners[1].config.extra_vars.to_json
|
71
|
+
command = "#{@pfexec} ansible-playbook ./providers/ansible/playbook.yml --tags 'install' -e '#{config}'"
|
64
72
|
_stdin, stdout, _stderr, wait_thr = Open3.popen3(command)
|
65
73
|
puts stdout.readline until stdout.eof?
|
66
74
|
wait_thr.value
|
@@ -92,8 +100,8 @@ module VagrantPlugins
|
|
92
100
|
|
93
101
|
## Boot the Machine
|
94
102
|
def boot(uii)
|
95
|
-
config = @machine.config.vm.provisioners[
|
96
|
-
command = "#{@pfexec} ansible-playbook ./providers/ansible/
|
103
|
+
config = @machine.config.vm.provisioners[1].config.extra_vars.to_json
|
104
|
+
command = "#{@pfexec} ansible-playbook ./providers/ansible/playbook.yml --tags 'boot' -e '#{config}'"
|
97
105
|
uii.info(I18n.t('vagrant_local.start'))
|
98
106
|
_stdin, stdout, _stderr, wait_thr = Open3.popen3(command)
|
99
107
|
puts stdout.readline until stdout.eof?
|
@@ -167,11 +175,11 @@ module VagrantPlugins
|
|
167
175
|
# Halts the instance, first via shutdown command, then a halt.
|
168
176
|
def halt(uii)
|
169
177
|
provider_config = @machine.provider_config
|
170
|
-
config = @machine.config.vm.provisioners[
|
178
|
+
config = @machine.config.vm.provisioners[1].config.extra_vars.to_json
|
171
179
|
uii.info(I18n.t('vagrant_local.graceful_shutdown'))
|
172
180
|
begin
|
173
181
|
Timeout.timeout(provider_config.clean_shutdown_time) do
|
174
|
-
command = "#{@pfexec} ansible-playbook ./providers/ansible/
|
182
|
+
command = "#{@pfexec} ansible-playbook ./providers/ansible/playbook.yml --tags 'halt' -e '#{config}' "
|
175
183
|
_stdin, stdout, _stderr, wait_thr = Open3.popen3(command)
|
176
184
|
puts stdout.readline until stdout.eof?
|
177
185
|
wait_thr.value
|
@@ -180,7 +188,7 @@ module VagrantPlugins
|
|
180
188
|
uii.info(I18n.t('vagrant_local.graceful_shutdown_failed') + provider_config.clean_shutdown_time.to_s)
|
181
189
|
begin
|
182
190
|
Timeout.timeout(provider_config.clean_shutdown_time) do
|
183
|
-
command = "#{@pfexec} ansible-playbook ./providers/ansible/
|
191
|
+
command = "#{@pfexec} ansible-playbook ./providers/ansible/playbook.yml --tags 'halt' -e '#{config}' "
|
184
192
|
_stdin, stdout, _stderr, wait_thr = Open3.popen3(command)
|
185
193
|
puts stdout.readline until stdout.eof?
|
186
194
|
wait_thr.value
|
@@ -193,10 +201,11 @@ module VagrantPlugins
|
|
193
201
|
|
194
202
|
# Destroys the instance
|
195
203
|
def destroy(id)
|
196
|
-
|
197
|
-
|
204
|
+
# byebug
|
205
|
+
config = @machine.config.vm.provisioners[1].config.extra_vars.to_json
|
206
|
+
if state == :stopped
|
198
207
|
id.info(I18n.t('vagrant_local.destroy'))
|
199
|
-
command = "#{@pfexec} ansible-playbook ./providers/ansible/
|
208
|
+
command = "#{@pfexec} ansible-playbook ./providers/ansible/playbook.yml --tags 'destroy' -e '#{config}' "
|
200
209
|
_stdin, stdout, _stderr, wait_thr = Open3.popen3(command)
|
201
210
|
puts stdout.readline until stdout.eof?
|
202
211
|
wait_thr.value
|
data/lib/vagrant-local/plugin.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
begin
|
4
4
|
require 'vagrant'
|
5
|
+
require 'yaml'
|
5
6
|
rescue LoadError
|
6
7
|
raise 'The Vagrant Local plugin must be run within Vagrant.'
|
7
8
|
end
|
@@ -19,11 +20,51 @@ module VagrantPlugins
|
|
19
20
|
require_relative 'config'
|
20
21
|
Config
|
21
22
|
end
|
23
|
+
|
22
24
|
provider(:local, parallel: false) do
|
23
25
|
require_relative 'provider'
|
24
26
|
Provider
|
25
27
|
end
|
26
28
|
|
29
|
+
config(:aws, :provider) do
|
30
|
+
require_relative 'config'
|
31
|
+
Config
|
32
|
+
end
|
33
|
+
|
34
|
+
provider(:aws, parallel: false) do
|
35
|
+
require_relative 'provider'
|
36
|
+
Provider
|
37
|
+
end
|
38
|
+
|
39
|
+
config(:azure, :provider) do
|
40
|
+
require_relative 'config'
|
41
|
+
Config
|
42
|
+
end
|
43
|
+
|
44
|
+
provider(:azure, parallel: false) do
|
45
|
+
require_relative 'provider'
|
46
|
+
Provider
|
47
|
+
end
|
48
|
+
|
49
|
+
config(:gcp, :provider) do
|
50
|
+
require_relative 'config'
|
51
|
+
Config
|
52
|
+
end
|
53
|
+
|
54
|
+
provider(:gcp, parallel: false) do
|
55
|
+
require_relative 'provider'
|
56
|
+
Provider
|
57
|
+
end
|
58
|
+
|
59
|
+
config(:prominic, :provider) do
|
60
|
+
require_relative 'config'
|
61
|
+
Config
|
62
|
+
end
|
63
|
+
|
64
|
+
provider(:prominic, parallel: false) do
|
65
|
+
require_relative 'provider'
|
66
|
+
Provider
|
67
|
+
end
|
27
68
|
# This initializes the internationalization strings.
|
28
69
|
def self.setup_i18n
|
29
70
|
I18n.load_path << File.expand_path('locales/en.yml', ProviderLocal.source_root)
|
@@ -66,7 +66,7 @@ module VagrantPlugins
|
|
66
66
|
def state
|
67
67
|
state_id = nil
|
68
68
|
state_id = :not_created unless @machine.id
|
69
|
-
state_id = driver.state
|
69
|
+
state_id = driver.state if @machine.id && !state_id
|
70
70
|
# This is a special pseudo-state so that we don't set the
|
71
71
|
# NOT_CREATED_ID while we're setting up the machine. This avoids
|
72
72
|
# clearing the data dir.
|
data/locales/en.yml
CHANGED
@@ -4,7 +4,7 @@ en:
|
|
4
4
|
not_created: |-
|
5
5
|
Your instance of this box haven't been created
|
6
6
|
is_running: |-
|
7
|
-
Your instance has already
|
7
|
+
Your instance has already been booted
|
8
8
|
errors:
|
9
9
|
not_yet_implemented: |-
|
10
10
|
Your configuration is not yet implemented
|
@@ -88,8 +88,8 @@ en:
|
|
88
88
|
Starting the instance
|
89
89
|
setting_dns_server: |-
|
90
90
|
Setting nameserver ==>
|
91
|
-
|
92
|
-
Detected
|
91
|
+
detected_format: |-
|
92
|
+
Detected
|
93
93
|
importing_box_image: |-
|
94
94
|
- Importing Box image ==>
|
95
95
|
importing_box_image_to_disk: |-
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-local
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Gilbert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|