infobloxopen / terraform-provider-infoblox

Infoblox NIOS Terraform Provider
https://github.com/infobloxopen/terraform-provider-infoblox
Mozilla Public License 2.0
68 stars 77 forks source link

Add HostRecord function #53

Closed scumola closed 4 years ago

scumola commented 4 years ago

This is a feature request.

There are calls for ip_allocation and ARecord, but not HostRecord. I'm guessing that this would be a copy/paste fix I'm guessing, but there's currently no way to add a HOST record, which is kinda important.

The example in the https://github.com/infobloxopen/terraform-provider-infoblox/tree/master/examples/VMware/HostRecord directory doesn't actually add a Host record even though the directory name implies that it does.

saiprasannasastry commented 4 years ago

the host record functionality is there. in the resource ip_allocation block , if you add zone, dns view parameters then it will create a host record . the enable dns flag is to enable dns. The ip allocation block does reservation if no mac address is given, fixed address if mac is given and host record if zone and dns view are given

scumola commented 4 years ago

adding those fields to the block causes a crash

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # infoblox_ip_allocation.demo_allocation will be updated in-place
  ~ resource "infoblox_ip_allocation" "demo_allocation" {
        cidr              = "10.120.0.0/13"
      + dns_view          = "Internal"
        enable_dns        = false
        id                = "fixedaddress/ZG5zLmZpeGVkX2FkZHJlc3MkMTAuMTIwLjguMjEuMC4u:10.120.8.21/default"
        ip_addr           = "10.120.8.21"
      + mac_addr          = "00:00:00:00:00:00"
        network_view_name = "default"
        tenant_id         = "domain.com"
        vm_name           = "test01.domain.com"
      + zone              = "domain.com"
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

infoblox_ip_allocation.demo_allocation: Modifying... [id=fixedaddress/ZG5zLmZpeGVkX2FkZHJlc3MkMTAuMTIwLjguMjEuMC4u:10.120.8.21/default]
infoblox_ip_allocation.demo_allocation: Still modifying... [id=fixedaddress/ZG5zLmZpeGVkX2FkZHJlc3MkMTAuMTIwLjguMjEuMC4u:10.120.8.21/default, 10s elapsed]
infoblox_ip_allocation.demo_allocation: Still modifying... [id=fixedaddress/ZG5zLmZpeGVkX2FkZHJlc3MkMTAuMTIwLjguMjEuMC4u:10.120.8.21/default, 20s elapsed]
infoblox_ip_allocation.demo_allocation: Still modifying... [id=fixedaddress/ZG5zLmZpeGVkX2FkZHJlc3MkMTAuMTIwLjguMjEuMC4u:10.120.8.21/default, 30s elapsed]
infoblox_ip_allocation.demo_allocation: Still modifying... [id=fixedaddress/ZG5zLmZpeGVkX2FkZHJlc3MkMTAuMTIwLjguMjEuMC4u:10.120.8.21/default, 40s elapsed]

Error: rpc error: code = Unavailable desc = transport is closing

panic: runtime error: index out of range [0] with length 0
2020-01-13T09:50:07.998-0700 [DEBUG] plugin.terraform-provider-infoblox:
2020-01-13T09:50:07.998-0700 [DEBUG] plugin.terraform-provider-infoblox: goroutine 124 [running]:
2020-01-13T09:50:07.998-0700 [DEBUG] plugin.terraform-provider-infoblox: github.com/infobloxopen/infoblox-go-client.(*ObjectManager).GetIpAddressFromHostRecord(...)
2020-01-13T09:50:07.998-0700 [DEBUG] plugin.terraform-provider-infoblox:    /Users/swebb/work/terraform-provider-infoblox/vendor/github.com/infobloxopen/infoblox-go-client/object_manager.go:486
2020-01-13T09:50:07.998-0700 [DEBUG] plugin.terraform-provider-infoblox: github.com/infobloxopen/terraform-provider-infoblox/infoblox.resourceIPAllocationUpdate(0xc0002bf2d0, 0x1bb6b20, 0xc0002dc090, 0x24, 0x2671d80)
2020-01-13T09:50:07.998-0700 [DEBUG] plugin.terraform-provider-infoblox:    /Users/swebb/work/terraform-provider-infoblox/infoblox/resourceIPAllocation.go:180 +0xcbd
2020-01-13T09:50:07.998-0700 [DEBUG] plugin.terraform-provider-infoblox: github.com/hashicorp/terraform/helper/schema.(*Resource).Apply(0xc00016ab00, 0xc00017fdb0, 0xc0006b7c60, 0x1bb6b20, 0xc0002dc090, 0xc0000c9f01, 0xc000144060, 0xc0000c9f78)
2020-01-13T09:50:07.998-0700 [DEBUG] plugin.terraform-provider-infoblox:    /Users/swebb/work/terraform-provider-infoblox/vendor/github.com/hashicorp/terraform/helper/schema/resource.go:311 +0x263
2020-01-13T09:50:07.998-0700 [DEBUG] plugin.terraform-provider-infoblox: github.com/hashicorp/terraform/helper/schema.(*Provider).Apply(0xc00016ad80, 0xc00022f8e0, 0xc00017fdb0, 0xc0006b7c60, 0xc0001f7048, 0xc0000cc948, 0x1b21480)
2020-01-13T09:50:07.998-0700 [DEBUG] plugin.terraform-provider-infoblox:    /Users/swebb/work/terraform-provider-infoblox/vendor/github.com/hashicorp/terraform/helper/schema/provider.go:289 +0x99
2020-01-13T09:50:07.998-0700 [DEBUG] plugin.terraform-provider-infoblox: github.com/hashicorp/terraform/helper/plugin.(*GRPCProviderServer).ApplyResourceChange(0xc0000104c0, 0x1ef6200, 0xc0001610e0, 0xc0006b8ba0, 0xc0000104c0, 0xc0001610e0, 0xc00007aa58)
2020-01-13T09:50:07.998-0700 [DEBUG] plugin.terraform-provider-infoblox:    /Users/swebb/work/terraform-provider-infoblox/vendor/github.com/hashicorp/terraform/helper/plugin/grpc_provider.go:885 +0x892
2020-01-13T09:50:07.999-0700 [DEBUG] plugin.terraform-provider-infoblox: github.com/hashicorp/terraform/internal/tfplugin5._Provider_ApplyResourceChange_Handler(0x1c5dfa0, 0xc0000104c0, 0x1ef6200, 0xc0001610e0, 0xc00017fa90, 0x0, 0x1ef6200, 0xc0001610e0, 0xc000015500, 0x2f6)
2020-01-13T09:50:07.999-0700 [DEBUG] plugin.terraform-provider-infoblox:    /Users/swebb/work/terraform-provider-infoblox/vendor/github.com/hashicorp/terraform/internal/tfplugin5/tfplugin5.pb.go:3189 +0x217
2020-01-13T09:50:07.999-0700 [DEBUG] plugin.terraform-provider-infoblox: google.golang.org/grpc.(*Server).processUnaryRPC(0xc0005a4a80, 0x1f02ee0, 0xc0005b2d80, 0xc0000b2e00, 0xc0004adce0, 0x26463c0, 0x0, 0x0, 0x0)
2020-01-13T09:50:07.999-0700 [DEBUG] plugin.terraform-provider-infoblox:    /Users/swebb/work/terraform-provider-infoblox/vendor/google.golang.org/grpc/server.go:998 +0x46a
2020-01-13T09:50:07.999-0700 [DEBUG] plugin.terraform-provider-infoblox: google.golang.org/grpc.(*Server).handleStream(0xc0005a4a80, 0x1f02ee0, 0xc0005b2d80, 0xc0000b2e00, 0x0)
2020-01-13T09:50:07.999-0700 [DEBUG] plugin.terraform-provider-infoblox:    /Users/swebb/work/terraform-provider-infoblox/vendor/google.golang.org/grpc/server.go:1278 +0xd97
2020-01-13T09:50:07.999-0700 [DEBUG] plugin.terraform-provider-infoblox: google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc000036250, 0xc0005a4a80, 0x1f02ee0, 0xc0005b2d80, 0xc0000b2e00)
2020-01-13T09:50:07.999-0700 [DEBUG] plugin.terraform-provider-infoblox:    /Users/swebb/work/terraform-provider-infoblox/vendor/google.golang.org/grpc/server.go:717 +0xbb
2020-01-13T09:50:07.999-0700 [DEBUG] plugin.terraform-provider-infoblox: created by google.golang.org/grpc.(*Server).serveStreams.func1
2020-01-13T09:50:07.999-0700 [DEBUG] plugin.terraform-provider-infoblox:    /Users/swebb/work/terraform-provider-infoblox/vendor/google.golang.org/grpc/server.go:715 +0xa1
2020/01/13 09:50:08 [DEBUG] infoblox_ip_allocation.demo_allocation: apply errored, but we're indicating that via the Error pointer rather than returning it: rpc error: code = Unavailable desc = transport is closing
2020/01/13 09:50:08 [TRACE] <root>: eval: *terraform.EvalMaybeTainted
2020/01/13 09:50:08 [TRACE] <root>: eval: *terraform.EvalWriteState
2020/01/13 09:50:08 [TRACE] EvalWriteState: writing current state object for infoblox_ip_allocation.demo_allocation
2020-01-13T09:50:08.001-0700 [DEBUG] plugin: plugin process exited: path=/Users/swebb/.terraform.d/plugins/terraform-provider-infoblox pid=4535 error="exit status 2"
2020/01/13 09:50:08 [TRACE] <root>: eval: *terraform.EvalApplyProvisioners
2020/01/13 09:50:08 [TRACE] EvalApplyProvisioners: infoblox_ip_allocation.demo_allocation is not freshly-created, so no provisioning is required
2020/01/13 09:50:08 [TRACE] <root>: eval: *terraform.EvalMaybeTainted
2020/01/13 09:50:08 [TRACE] <root>: eval: *terraform.EvalWriteState
2020/01/13 09:50:08 [TRACE] EvalWriteState: writing current state object for infoblox_ip_allocation.demo_allocation
2020/01/13 09:50:08 [TRACE] <root>: eval: *terraform.EvalIf
2020/01/13 09:50:08 [TRACE] <root>: eval: *terraform.EvalIf
2020/01/13 09:50:08 [TRACE] <root>: eval: *terraform.EvalWriteDiff
2020/01/13 09:50:08 [TRACE] <root>: eval: *terraform.EvalApplyPost
2020/01/13 09:50:08 [ERROR] <root>: eval: *terraform.EvalApplyPost, err: rpc error: code = Unavailable desc = transport is closing
2020/01/13 09:50:08 [ERROR] <root>: eval: *terraform.EvalSequence, err: rpc error: code = Unavailable desc = transport is closing
2020/01/13 09:50:08 [TRACE] [walkApply] Exiting eval tree: infoblox_ip_allocation.demo_allocation
2020/01/13 09:50:08 [TRACE] vertex "infoblox_ip_allocation.demo_allocation": visit complete
2020/01/13 09:50:08 [TRACE] dag/walk: upstream of "provider.infoblox (close)" errored, so skipping
2020/01/13 09:50:08 [TRACE] dag/walk: upstream of "meta.count-boundary (EachMode fixup)" errored, so skipping
2020/01/13 09:50:08 [TRACE] dag/walk: upstream of "root" errored, so skipping
2020/01/13 09:50:08 [TRACE] statemgr.Filesystem: creating backup snapshot at terraform.tfstate.backup
2020/01/13 09:50:08 [TRACE] statemgr.Filesystem: state has changed since last snapshot, so incrementing serial to 251
2020/01/13 09:50:08 [TRACE] statemgr.Filesystem: writing snapshot at terraform.tfstate
2020/01/13 09:50:08 [TRACE] statemgr.Filesystem: removing lock metadata file .terraform.tfstate.lock.info
2020/01/13 09:50:08 [TRACE] statemgr.Filesystem: unlocking terraform.tfstate using fcntl flock
2020-01-13T09:50:08.033-0700 [DEBUG] plugin: plugin exited

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Terraform crashed! This is always indicative of a bug within Terraform.
A crash log has been placed at "crash.log" relative to your current
working directory. It would be immensely helpful if you could please
report the crash with Terraform[1] so that we can fix this.

When reporting bugs, please include your terraform version. That
information is available on the first line of crash.log. You can also
get it by running 'terraform --version' on the command line.

[1]: https://github.com/hashicorp/terraform/issues

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!
$
saiprasannasastry commented 4 years ago

Hi, why is this id = "fixedaddress/ZG5zLmZpeGVkX2FkZHJlc3MkMTAuMTIwLjguMjEuMC4u:10.120.8.21/default" given? also please note you can't update a fixed address to a host record. you will need to create a new template probably in a different folder or else terraform will try to update it. point 2 from what i understand from the previous bugs as well, you have a state file with the resource but that is not there in infoblox, now you are trying to update that to host record. Please correct me if i am wrong. Like i said in previous comments if the resource is deleted from NIOS manually you cant rerun terraform and expect it to create.

scumola commented 4 years ago

The field: fixedaddress/ZG5zLmZpeGVkX2FkZHJlc3MkMTAuMTIwLjguMjEuMC4u:10.120.8.21/default was something that terraform provided that must have been in the state file. My terraform block was:

resource "infoblox_ip_allocation" "demo_allocation"{
  vm_name="test01.domain.com"
  ip_addr = aws_instance.test01.private_ip
  cidr="10.120.0.0/13"
  mac_addr = "00:00:00:00:00:00"
  tenant_id="domain.com"
  zone="domain.com"
  dns_view="Internal"
  enable_dns=false
}

Regarding your second question, the IP address did exist in this case.

image

Q: How come terraform won't re-create a missing entry that it expects to be there? Q: How come terraform won't change or delete/create an entry that is changed? I'm pretty sure that this is common behavior for terraform. I specify what I want as resources and terraform does what's necessary to make that happen. I shouldn't have to go and massage the resources by-hand to make terraform happy.

NickLarsenNZ commented 4 years ago

@saiprasannasastry seems like this issue should be opened again :)