vagrant-terraform 0.1.10 → 0.1.12
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e305adfd79a1c56e8812dd068a5b2502a34236603ba57e1285597459d3e6387
|
4
|
+
data.tar.gz: db6c7c8e2235700b96fe3b548265b40fcb1624259e22f2efa036aabd293e6208
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa6c9c6524467a8adf146fb8e41110df58d877e9f02de05252cfa776a6d37e0189b32c0ee1c1e342e4841155344791ffe28af32ea45f24625eb9491d663a364a
|
7
|
+
data.tar.gz: 246a8498c3cfa9ff61cf48fe713ccc1f838fe774858021c7194d5699d96dec3890b6aaf727ac8ffe27b361a1efef0b15937fa059ab336d0c4205a34f5016580f
|
@@ -45,13 +45,14 @@ provider "proxmox" {
|
|
45
45
|
resource "proxmox_vm_qemu" "#{vmname.gsub(/\./, '-')}" {
|
46
46
|
name = "#{vmname}"
|
47
47
|
target_nodes = ["#{config.target_node}"]
|
48
|
-
desc
|
48
|
+
desc = "#{config.description}"
|
49
49
|
vm_state = "stopped"
|
50
50
|
clone = "#{config.template}"
|
51
51
|
full_clone = "#{config.full_clone}"
|
52
52
|
cores = #{config.cpu_cores.to_i}
|
53
|
+
cpu_type = "#{config.cpu_type}"
|
53
54
|
memory = #{Filesize.from("#{config.memory_size} B").to_f('MiB').to_i}
|
54
|
-
onboot
|
55
|
+
onboot = #{config.onboot}
|
55
56
|
agent = 1
|
56
57
|
vga {
|
57
58
|
type = "#{config.vga}"
|
@@ -170,11 +171,55 @@ END
|
|
170
171
|
terraform_main_file = "#{terraform_dir}/main.tf"
|
171
172
|
|
172
173
|
File.write(terraform_main_file, main_tf)
|
173
|
-
|
174
|
+
|
175
|
+
# Avoid downloading the provider every time even when it's in the cache
|
176
|
+
ENV['TF_PLUGIN_CACHE_MAY_BREAK_DEPENDENCY_LOCK_FILE'] = "1"
|
177
|
+
retryable(on: Errors::TerraformError, tries: 100, sleep: 1) do
|
178
|
+
begin
|
179
|
+
terraform_execute(env, 'terraform init')
|
180
|
+
rescue Errors::TerraformError => e
|
181
|
+
# https://github.com/hashicorp/terraform/issues/32915
|
182
|
+
# https://github.com/hashicorp/terraform/issues/31964
|
183
|
+
# The message 'text file busy' comes when something is attempting to overwrite the executable
|
184
|
+
# for a running process which is using the same data. The plugin cache is not safe for concurrent
|
185
|
+
# access, and overwriting running providers can result in unexpected behavior.
|
186
|
+
ansi_escape_regex = /\e\[(?:[0-9]{1,2}(?:;[0-9]{1,2})*)?[m|K]/
|
187
|
+
if e.message.gsub(ansi_escape_regex, '').include?("Failed to install provider")
|
188
|
+
@logger.debug("Failed to install provider, retrying")
|
189
|
+
raise e
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
174
193
|
|
175
194
|
retryable(on: Errors::TerraformError, tries: 10, sleep: 1) do
|
176
195
|
begin
|
177
|
-
|
196
|
+
lockfile = '.vagrant/terraform/lock'
|
197
|
+
max_retries = 300
|
198
|
+
retry_delay = 2
|
199
|
+
|
200
|
+
File.open(lockfile, 'w') do |file|
|
201
|
+
retries = 0
|
202
|
+
|
203
|
+
# VM creation can't be done in parallel because multiple VMs might get the same ID
|
204
|
+
# Get a lock before creating VM with 'terraform apply'
|
205
|
+
until file.flock(File::LOCK_EX | File::LOCK_NB)
|
206
|
+
if retries >= max_retries
|
207
|
+
raise Errors::CreateVMError,
|
208
|
+
:error_message => "Failed to acquire lock after #{max_retries} attempts. Exiting."
|
209
|
+
end
|
210
|
+
|
211
|
+
@logger.debug("Lock is currently held. Retrying in #{retry_delay} seconds...")
|
212
|
+
retries += 1
|
213
|
+
sleep(retry_delay)
|
214
|
+
end
|
215
|
+
|
216
|
+
begin
|
217
|
+
terraform_execute(env, "terraform apply -auto-approve")
|
218
|
+
ensure
|
219
|
+
file.flock(File::LOCK_UN)
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
178
223
|
rescue Errors::TerraformError => e
|
179
224
|
# ==> vm_one: terraform stderr: ╷
|
180
225
|
# ==> vm_one: │ Error: can't lock file '/var/lock/qemu-server/lock-100.conf' - got timeout
|
@@ -193,7 +238,7 @@ END
|
|
193
238
|
|
194
239
|
# Terraform error message was 'clone failed: 'storage-qnap-nfs'-locked command timed out - aborting'
|
195
240
|
if e.message.gsub(ansi_escape_regex, '').include?("command timed out")
|
196
|
-
env[:ui].info("Proxmox clone failed, retrying")
|
241
|
+
env[:ui].info("Proxmox clone failed with command timeout, retrying")
|
197
242
|
raise e
|
198
243
|
end
|
199
244
|
|
@@ -205,7 +250,26 @@ END
|
|
205
250
|
|
206
251
|
# Terraform error message was 'volume 'qnap-nfs:104/vm-104-disk-1.raw' does not exist'
|
207
252
|
if e.message.gsub(ansi_escape_regex, '') =~ /.*volume .* does not exist/
|
208
|
-
|
253
|
+
# https://github.com/bpg/terraform-provider-proxmox/issues/1599
|
254
|
+
env[:ui].info("Volume not created, retrying. Error was: #{e.message}")
|
255
|
+
raise e
|
256
|
+
end
|
257
|
+
|
258
|
+
# Terraform error message was 'clone failed: disk image '/mnt/pve/qnap-nfs/images/104/vm-104-cloudinit.qcow2' already exists'
|
259
|
+
if e.message.gsub(ansi_escape_regex, '') =~ /.*disk image .* already exists/
|
260
|
+
env[:ui].info("Clone failed, retrying. Error was: #{e.message}")
|
261
|
+
raise e
|
262
|
+
end
|
263
|
+
|
264
|
+
# Terraform error message was "clone failed: unable to create image: qemu-img: /mnt/pve/qnap-nfs/images/105/vm-105-cloudinit.qcow2: Could not create '/mnt/pve/qnap-nfs/images/105/vm-105-cloudinit.qcow2': No such file or directory"
|
265
|
+
if e.message.gsub(ansi_escape_regex, '') =~ /.*unable to create image: .* No such file or directory/
|
266
|
+
env[:ui].info("Clone failed, retrying. Error was: #{e.message}")
|
267
|
+
raise e
|
268
|
+
end
|
269
|
+
|
270
|
+
# Terraform error message was 'Request cancelled'
|
271
|
+
if e.message.gsub(ansi_escape_regex, '').include?("Request cancelled")
|
272
|
+
env[:ui].info("Proxmox error: Request cancelled")
|
209
273
|
raise e
|
210
274
|
end
|
211
275
|
|
@@ -22,6 +22,7 @@ module VagrantPlugins
|
|
22
22
|
# dir_name = env[:root_path].basename.to_s.dup.gsub(/[^-a-z0-9_]/i, "")
|
23
23
|
begin
|
24
24
|
Dir.mkdir(File.dirname(terraform_dir)) unless File.exist?(File.dirname(terraform_dir))
|
25
|
+
FileUtils.touch("#{File.dirname(terraform_dir)}/lock")
|
25
26
|
rescue => e
|
26
27
|
retry if e.message =~ /File exists/
|
27
28
|
env[:ui].error("terraform init failed: #{e.message}")
|
@@ -17,6 +17,7 @@ module VagrantPlugins
|
|
17
17
|
attr_accessor :disk_size
|
18
18
|
attr_accessor :storage_domain
|
19
19
|
attr_accessor :cpu_cores
|
20
|
+
attr_accessor :cpu_type
|
20
21
|
attr_accessor :memory_size
|
21
22
|
attr_accessor :target_node
|
22
23
|
attr_accessor :onboot
|
@@ -31,7 +32,7 @@ module VagrantPlugins
|
|
31
32
|
@api_url = UNSET_VALUE
|
32
33
|
@api_token_id = UNSET_VALUE
|
33
34
|
@api_token_secret = UNSET_VALUE
|
34
|
-
@vga
|
35
|
+
@vga = UNSET_VALUE
|
35
36
|
@insecure = UNSET_VALUE
|
36
37
|
@debug = UNSET_VALUE
|
37
38
|
@vmname = UNSET_VALUE
|
@@ -39,6 +40,7 @@ module VagrantPlugins
|
|
39
40
|
@disk_size = UNSET_VALUE
|
40
41
|
@storage_domain = UNSET_VALUE
|
41
42
|
@cpu_cores = UNSET_VALUE
|
43
|
+
@cpu_type = UNSET_VALUE
|
42
44
|
@memory_size = UNSET_VALUE
|
43
45
|
@target_node = UNSET_VALUE
|
44
46
|
@onboot = UNSET_VALUE
|
@@ -62,6 +64,7 @@ module VagrantPlugins
|
|
62
64
|
@disk_size = nil if @disk_size == UNSET_VALUE
|
63
65
|
@storage_domain = nil if @storage_domain == UNSET_VALUE
|
64
66
|
@cpu_cores = 1 if @cpu_cores == UNSET_VALUE
|
67
|
+
@cpu_type = 'host' if @cpu_type == UNSET_VALUE
|
65
68
|
@memory_size = '512 MiB' if @memory_size == UNSET_VALUE
|
66
69
|
@target_node = nil if @target_node == UNSET_VALUE
|
67
70
|
@onboot = false if @onboot == UNSET_VALUE
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-terraform
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mika Båtsman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: filesize
|