vagrant-local 0.0.1 → 0.0.2

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: a1d8c9dce1b4dae4a69c98cc147082953ebfc7d9c487f8fca9db2db279cffadd
4
- data.tar.gz: 50f67b0bb0ad9dc4d150672cae497e501163d5c2fd21044a2ec53fcbe21e3c8c
3
+ metadata.gz: 3e8832438f1e44676aca1406ba999ade22e226da20cfce80f421fe60371382e2
4
+ data.tar.gz: 378419aa3ca92637137742c25bcdf60080019146bcce245aa4a9757d990055cb
5
5
  SHA512:
6
- metadata.gz: 18b3cc80cdb68f8f4aa070510e30ac44e6f1fc54975dd83eb9d38ac1254160d39d9257ac1e6b73bebfc9f1033f4474deb1b8fc510467f0ca5cd0a166a39c7dca
7
- data.tar.gz: b30cd4213fe601d934e0c022cdeef40900b270ec805e71ec778978697775457358491b380535ae76b10276ac747ba394b0789470b2a86ecc7ecb70e1fbb2ee5e
6
+ metadata.gz: c8f3a53c97c9336e573e8f03905be56ec1d33f78fafb64a3255ff7e8ef9db3ebfd008684336650e87d71f732b889c67487df48efb856d03e8bb144ad8b3a7833
7
+ data.tar.gz: 6c5c020d2a53a1333923c28de16784aca14751deac47cab3beb1a6f1b21187f9a44ba74fbda1cf2d72966234f1b6a14af6c8e40e7f813203bda35ca6011e948a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.0.2](https://github.com/STARTcloud/vagrant-local/compare/v0.0.1...v0.0.2) (2024-01-17)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * box format auto-detect ([0d205f2](https://github.com/STARTcloud/vagrant-local/commit/0d205f2b2c0517669d1057cc1abc11f7f650cb9e))
9
+ * call playbook instead of invidual plays ([8ebab01](https://github.com/STARTcloud/vagrant-local/commit/8ebab01374e7dc9b03a985ff862654a59add3afe))
10
+
3
11
  ## [0.0.1](https://github.com/STARTcloud/vagrant-local/compare/v1.0.1...v0.0.1) (2024-01-15)
4
12
 
5
13
 
@@ -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
- state_id = @driver.state(@machine)
35
- ui.info(I18n.t('vagrant_local.graceful_shutdown_complete')) unless state_id == :running
36
- sleep 1 if state_id == :running
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
@@ -18,6 +18,9 @@ module VagrantPlugins
18
18
  env[:halt_on_error] = true
19
19
  b2.use action_start
20
20
  elsif !env[:result]
21
+ b2.use Import
22
+ b2.use HandleBox
23
+ b2.use BoxCheckOutdated
21
24
  b2.use Create
22
25
  b2.use Start
23
26
  b2.use WaitTillBoot
@@ -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
- # rubocop:disable Layout/LineLength
10
- attr_accessor :brand, :autoboot, :setup_method, :safe_restart, :allowed_address, :post_provision_boot, :safe_shutdown, :boxshortname, :kernel, :debug, :debug_boot, :private_network, :winalcheck, :winlcheck, :lcheck, :alcheck, :snapshot_script, :diskif, :netif, :cdroms, :disk1path, :disk1size, :cpus, :cpu_configuration, :boot, :complex_cpu_conf, :memory, :vagrant_user, :vagrant_user_private_key_path, :setup_wait, :on_demand_vnics, :clean_shutdown_time, :dhcp4, :vagrant_user_pass, :firmware_type, :vm_type, :partition_id, :shared_disk_enabled, :shared_dir, :acpi, :os_type, :console, :consolehost, :consoleport, :console_onboot, :hostbridge, :sshport, :rdpport, :override, :additional_disks, :cloud_init_resolvers, :cloud_init_enabled, :cloud_init_dnsdomain, :cloud_init_password, :cloud_init_sshkey, :cloud_init_conf, :dns, :box, :vagrant_cloud_creator, :winbooted_string, :booted_string, :zunlockbootkey, :zunlockboot, :xhci_enabled, :login_wait
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 = 'bhyve'
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
@@ -37,8 +37,17 @@ module VagrantPlugins
37
37
  end
38
38
  end
39
39
 
40
- def state(machine)
41
- vm_data = YAML.load_file("#{machine.name}.vmstate")
40
+ def state
41
+ data = [{
42
+ 'name' => nil,
43
+ 'ec2_id' => nil,
44
+ 'state' => 'not_created',
45
+ 'public_ip' => nil
46
+ }]
47
+ vmstate_file = "#{@machine.name}.vmstate"
48
+ File.write(vmstate_file, data.to_yaml) unless File.exist?(vmstate_file)
49
+
50
+ vm_data = YAML.load_file(vmstate_file)
42
51
  return :not_created unless vm_data.is_a?(Array) && !vm_data.empty? && vm_data.first.is_a?(Hash)
43
52
 
44
53
  vm_state = vm_data.first['state']
@@ -59,8 +68,8 @@ module VagrantPlugins
59
68
 
60
69
  ## Begin installation
61
70
  def install(_uii)
62
- config = @machine.config.vm.provisioners[0].config.extra_vars.to_json
63
- command = "#{@pfexec} ansible-playbook ./providers/ansible/install.yml -e '#{config}'"
71
+ config = @machine.config.vm.provisioners[1].config.extra_vars.to_json
72
+ command = "#{@pfexec} ansible-playbook ./providers/ansible/playbook.yml --tags 'install' -e '#{config}'"
64
73
  _stdin, stdout, _stderr, wait_thr = Open3.popen3(command)
65
74
  puts stdout.readline until stdout.eof?
66
75
  wait_thr.value
@@ -92,8 +101,8 @@ module VagrantPlugins
92
101
 
93
102
  ## Boot the Machine
94
103
  def boot(uii)
95
- config = @machine.config.vm.provisioners[0].config.extra_vars.to_json
96
- command = "#{@pfexec} ansible-playbook ./providers/ansible/boot.yml -e '#{config}'"
104
+ config = @machine.config.vm.provisioners[1].config.extra_vars.to_json
105
+ command = "#{@pfexec} ansible-playbook ./providers/ansible/playbook.yml --tags 'boot' -e '#{config}'"
97
106
  uii.info(I18n.t('vagrant_local.start'))
98
107
  _stdin, stdout, _stderr, wait_thr = Open3.popen3(command)
99
108
  puts stdout.readline until stdout.eof?
@@ -167,11 +176,11 @@ module VagrantPlugins
167
176
  # Halts the instance, first via shutdown command, then a halt.
168
177
  def halt(uii)
169
178
  provider_config = @machine.provider_config
170
- config = @machine.config.vm.provisioners[0].config.extra_vars.to_json
179
+ config = @machine.config.vm.provisioners[1].config.extra_vars.to_json
171
180
  uii.info(I18n.t('vagrant_local.graceful_shutdown'))
172
181
  begin
173
182
  Timeout.timeout(provider_config.clean_shutdown_time) do
174
- command = "#{@pfexec} ansible-playbook ./providers/ansible/halt.yml -e '#{config}'"
183
+ command = "#{@pfexec} ansible-playbook ./providers/ansible/playbook.yml --tags 'halt' -e '#{config}' "
175
184
  _stdin, stdout, _stderr, wait_thr = Open3.popen3(command)
176
185
  puts stdout.readline until stdout.eof?
177
186
  wait_thr.value
@@ -180,7 +189,7 @@ module VagrantPlugins
180
189
  uii.info(I18n.t('vagrant_local.graceful_shutdown_failed') + provider_config.clean_shutdown_time.to_s)
181
190
  begin
182
191
  Timeout.timeout(provider_config.clean_shutdown_time) do
183
- command = "#{@pfexec} ansible-playbook ./providers/ansible/halt.yml -e '#{config}'"
192
+ command = "#{@pfexec} ansible-playbook ./providers/ansible/playbook.yml --tags 'halt' -e '#{config}' "
184
193
  _stdin, stdout, _stderr, wait_thr = Open3.popen3(command)
185
194
  puts stdout.readline until stdout.eof?
186
195
  wait_thr.value
@@ -193,10 +202,11 @@ module VagrantPlugins
193
202
 
194
203
  # Destroys the instance
195
204
  def destroy(id)
196
- config = @machine.config.vm.provisioners[0].config.extra_vars.to_json
197
- if state(@machine) == :stopped
205
+ # byebug
206
+ config = @machine.config.vm.provisioners[1].config.extra_vars.to_json
207
+ if state == :stopped
198
208
  id.info(I18n.t('vagrant_local.destroy'))
199
- command = "#{@pfexec} ansible-playbook ./providers/ansible/destroy.yml -e '#{config}'"
209
+ command = "#{@pfexec} ansible-playbook ./providers/ansible/playbook.yml --tags 'destroy' -e '#{config}' "
200
210
  _stdin, stdout, _stderr, wait_thr = Open3.popen3(command)
201
211
  puts stdout.readline until stdout.eof?
202
212
  wait_thr.value
@@ -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(@machine) if @machine.id && !state_id
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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  module VagrantPlugins
4
4
  module ProviderLocal
5
- VERSION = '0.0.1'
5
+ VERSION = '0.0.2'
6
6
  NAME = 'vagrant-local'
7
7
  end
8
8
  end
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 be booted
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
- detected_ovf_format: |-
92
- Detected OVF
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.1
4
+ version: 0.0.2
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-15 00:00:00.000000000 Z
11
+ date: 2024-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n