Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with validating and applying the code #2

Open
alifiroozabadi opened this issue May 7, 2023 · 3 comments
Open

Error with validating and applying the code #2

alifiroozabadi opened this issue May 7, 2023 · 3 comments

Comments

@alifiroozabadi
Copy link

When I use "terraform -validate" I get these error :
│ Error: Unsupported block type

│ on main.tf line 112:
│ 112: provisioner "file" {

│ Blocks of type "provisioner" are not expected here.


│ Error: Unsupported block type

│ on main.tf line 117:
│ 117: provisioner "local-exec" {

│ Blocks of type "provisioner" are not expected here.

If I use both provisioner blocks and in the (resource "vsphere_virtual_machine" "standalone") block the error change to :
│ Error: Missing required argument

│ on main.tf line 100, in resource "vsphere_virtual_machine" "standalone":
│ 100: provisioner "local-exec" {

│ The argument "command" is required, but no definition was found.


│ Error: Unsupported argument

│ on main.tf line 101, in resource "vsphere_virtual_machine" "standalone":
│ 101: inline = [

│ An argument named "inline" is not expected here.

I edited provisioners code with this and I can validate the code:

Run command on the local machine to run Ansible

provisioner "local-exec" {
command = "ansible-playbook playbook.yml"
}

But when I use "terraform apply " , after cloning from template the cli return this error :
Error: error reconfiguring virtual machine: error reconfiguring virtual machine: Invalid operation for device '3'.

│ with vsphere_virtual_machine.standalone,
│ on main.tf line 53, in resource "vsphere_virtual_machine" "standalone":
│ 53: resource "vsphere_virtual_machine" "standalone" {

Did anyone face with this error ?

@alifiroozabadi
Copy link
Author

I found some useful links about ""Invalid operation for device '3'"", it seems it's a bug about vSphere provider and also reported here: hashicorp/terraform-provider-vsphere#1016
The workaround suggested here in the link below:
""https://sestegra.medium.com/contribute-to-open-source-2bd2a738d6d5""
I should use vSphere provider below "1.15.0"

@stefangweichinger
Copy link

When I use "terraform -validate" I get these error : │ Error: Unsupported block type │ │ on main.tf line 112: │ 112: provisioner "file" { │ │ Blocks of type "provisioner" are not expected here. ╵ ╷ │ Error: Unsupported block type │ │ on main.tf line 117: │ 117: provisioner "local-exec" { │ │ Blocks of type "provisioner" are not expected here.

If I use both provisioner blocks and in the (resource "vsphere_virtual_machine" "standalone") block the error change to : │ Error: Missing required argument │ │ on main.tf line 100, in resource "vsphere_virtual_machine" "standalone": │ 100: provisioner "local-exec" { │ │ The argument "command" is required, but no definition was found. ╵ ╷ │ Error: Unsupported argument │ │ on main.tf line 101, in resource "vsphere_virtual_machine" "standalone": │ 101: inline = [ │ │ An argument named "inline" is not expected here.

I also hit the first error with Blocks of type "provisioner" are not expected here.. Unsure how to proceed, would you share your changes, @alifiroozabadi ?

@alifiroozabadi
Copy link
Author

When I use "terraform -validate" I get these error : │ Error: Unsupported block type │ │ on main.tf line 112: │ 112: provisioner "file" { │ │ Blocks of type "provisioner" are not expected here. ╵ ╷ │ Error: Unsupported block type │ │ on main.tf line 117: │ 117: provisioner "local-exec" { │ │ Blocks of type "provisioner" are not expected here.
If I use both provisioner blocks and in the (resource "vsphere_virtual_machine" "standalone") block the error change to : │ Error: Missing required argument │ │ on main.tf line 100, in resource "vsphere_virtual_machine" "standalone": │ 100: provisioner "local-exec" { │ │ The argument "command" is required, but no definition was found. ╵ ╷ │ Error: Unsupported argument │ │ on main.tf line 101, in resource "vsphere_virtual_machine" "standalone": │ 101: inline = [ │ │ An argument named "inline" is not expected here.

I also hit the first error with Blocks of type "provisioner" are not expected here.. Unsure how to proceed, would you share your changes, @alifiroozabadi ?

Using VMware provider 1.15.0 worked for me.
You can find my working code here :
https://github.com/alifiroozabadi/Terraform-Vsphere/tree/main/Create-VM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants