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

plugin doesn't suppor correct zone update #26

Open
kazarin-ka opened this issue Feb 17, 2019 · 0 comments
Open

plugin doesn't suppor correct zone update #26

kazarin-ka opened this issue Feb 17, 2019 · 0 comments

Comments

@kazarin-ka
Copy link

If you use this plugin in custom module with mass resoucre creation, it doesn't support to create one record per host - in rewrites full infomation about DNS zone.
So after terraform task completion, only last DNS record (A for example) is avialiable.

Example of code ( module template):

resource "hcloud_server" "server" {
  count = "${var.count}"
  name = "${format("${var.server_name}%02d", count.index + "${var.count_offset}" + 1)}"
  image = "${var.server_base_image}"
  server_type = "${var.server_type}"
  ssh_keys = ["${var.ssh_key_list}"]
  datacenter = "${var.datacenter}"

   provisioner "remote-exec" {
     connection = {
       type = "ssh"
       port = "${var.ssh_port}"
       user = "${var.ssh_user}"
       private_key = "${file(var.ssh_private_key)}"
       host = "${self.ipv4_address}"
       script_path = "/root/terrainit.sh"
     }
     inline = [
       "hostname",
       "uptime"
     ]
   }

}

resource "hcloud_volume" "data_disk" {
  count = "${var.count}"
  name = "sdb_${format("${var.server_name}%02d", count.index + "${var.count_offset}" + 1)}"
  size = "${var.data_disk_size}"
  location = "${var.location}"
}

resource "hcloud_volume_attachment" "data_disk" {
  count = "${var.count}"
  # https://www.terraform.io/docs/configuration/interpolation.html#element-list-index-
  volume_id = "${element(hcloud_volume.data_disk.*.id, count.index)}"
  server_id = "${element(hcloud_server.server.*.id, count.index)}"

  automount = true
}

resource "godaddy_domain_record" "server_A_record" {
  count = "${var.count}"
  domain   = "${var.domain}"
  customer = "${var.dns_godaddy_client_number}"
  record {
    name = "${format("${var.server_name}%02d", count.index + "${var.count_offset}" + 1)}"
    type = "A"
    data = "${element(hcloud_server.server.*.ipv4_address, count.index)}"
    ttl = 600
  }
}

terraform apply log:

Terraform will perform the following actions:

  + module.frontend.godaddy_domain_record.server_A_record[0]
      id:                          <computed>
      domain:                      "giftbro.xyz"
      record.#:                    "1"
      record.~4039003554.data:     "${element(hcloud_server.server.*.ipv4_address, count.index)}"
      record.~4039003554.name:     "gift-bro-front01"
      record.~4039003554.priority: "0"
      record.~4039003554.ttl:      "600"
      record.~4039003554.type:     "A"

  + module.frontend.godaddy_domain_record.server_A_record[1]
      id:                          <computed>
      domain:                      "giftbro.xyz"
      record.#:                    "1"
      record.~4066396805.data:     "${element(hcloud_server.server.*.ipv4_address, count.index)}"
      record.~4066396805.name:     "gift-bro-front02"
      record.~4066396805.priority: "0"
      record.~4066396805.ttl:      "600"
      record.~4066396805.type:     "A"

  + module.frontend.hcloud_server.server[0]
      id:                          <computed>
      backup_window:               <computed>
      backups:                     "false"
      datacenter:                  "hel1-dc2"
      image:                       "centos-7"
      ipv4_address:                <computed>
      ipv6_address:                <computed>
      ipv6_network:                <computed>
      keep_disk:                   "false"
      location:                    <computed>
      name:                        "gift-bro-front01"
      server_type:                 "cx11"
      ssh_keys.#:                  "1"
      ssh_keys.0:                  "429406"
      status:                      <computed>

  + module.frontend.hcloud_server.server[1]
      id:                          <computed>
      backup_window:               <computed>
      backups:                     "false"
      datacenter:                  "hel1-dc2"
      image:                       "centos-7"
      ipv4_address:                <computed>
      ipv6_address:                <computed>
      ipv6_network:                <computed>
      keep_disk:                   "false"
      location:                    <computed>
      name:                        "gift-bro-front02"
      server_type:                 "cx11"
      ssh_keys.#:                  "1"
      ssh_keys.0:                  "429406"
      status:                      <computed>

  + module.frontend.hcloud_volume.data_disk[0]
      id:                          <computed>
      linux_device:                <computed>
      location:                    "hel1"
      name:                        "sdb_gift-bro-front01"
      server_id:                   <computed>
      size:                        "10"

  + module.frontend.hcloud_volume.data_disk[1]
      id:                          <computed>
      linux_device:                <computed>
      location:                    "hel1"
      name:                        "sdb_gift-bro-front02"
      server_id:                   <computed>
      size:                        "10"

  + module.frontend.hcloud_volume_attachment.data_disk[0]
      id:                          <computed>
      automount:                   "true"
      server_id:                   "0"
      volume_id:                   "0"

  + module.frontend.hcloud_volume_attachment.data_disk[1]
      id:                          <computed>
      automount:                   "true"
      server_id:                   "0"
      volume_id:                   "0"


Plan: 8 to add, 0 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

module.frontend.hcloud_volume.data_disk[0]: Creating...
  linux_device: "" => "<computed>"
  location:     "" => "hel1"
  name:         "" => "sdb_gift-bro-front01"
  server_id:    "" => "<computed>"
  size:         "" => "10"
module.frontend.hcloud_volume.data_disk[1]: Creating...
  linux_device: "" => "<computed>"
  location:     "" => "hel1"
  name:         "" => "sdb_gift-bro-front02"
  server_id:    "" => "<computed>"
  size:         "" => "10"
module.frontend.hcloud_server.server[0]: Creating...
  backup_window: "" => "<computed>"
  backups:       "" => "false"
  datacenter:    "" => "hel1-dc2"
  image:         "" => "centos-7"
  ipv4_address:  "" => "<computed>"
  ipv6_address:  "" => "<computed>"
  ipv6_network:  "" => "<computed>"
  keep_disk:     "" => "false"
  location:      "" => "<computed>"
  name:          "" => "gift-bro-front01"
  server_type:   "" => "cx11"
  ssh_keys.#:    "" => "1"
  ssh_keys.0:    "" => "429406"
  status:        "" => "<computed>"
module.frontend.hcloud_server.server[1]: Creating...
  backup_window: "" => "<computed>"
  backups:       "" => "false"
  datacenter:    "" => "hel1-dc2"
  image:         "" => "centos-7"
  ipv4_address:  "" => "<computed>"
  ipv6_address:  "" => "<computed>"
  ipv6_network:  "" => "<computed>"
  keep_disk:     "" => "false"
  location:      "" => "<computed>"
  name:          "" => "gift-bro-front02"
  server_type:   "" => "cx11"
  ssh_keys.#:    "" => "1"
  ssh_keys.0:    "" => "429406"
  status:        "" => "<computed>"
module.frontend.hcloud_volume.data_disk[1]: Creation complete after 2s (ID: 1844720)
module.frontend.hcloud_volume.data_disk[0]: Creation complete after 2s (ID: 1844721)
module.frontend.hcloud_server.server.0: Still creating... (10s elapsed)
module.frontend.hcloud_server.server.1: Still creating... (10s elapsed)
module.frontend.hcloud_server.server[0]: Provisioning with 'remote-exec'...
module.frontend.hcloud_server.server[0] (remote-exec): Connecting to remote host via SSH...
module.frontend.hcloud_server.server[0] (remote-exec):   Host: 95.216.185.25
module.frontend.hcloud_server.server[0] (remote-exec):   User: root
module.frontend.hcloud_server.server[0] (remote-exec):   Password: false
module.frontend.hcloud_server.server[0] (remote-exec):   Private key: true
module.frontend.hcloud_server.server[0] (remote-exec):   SSH Agent: true
module.frontend.hcloud_server.server[0] (remote-exec):   Checking Host Key: false
module.frontend.hcloud_server.server[1]: Provisioning with 'remote-exec'...
module.frontend.hcloud_server.server[1] (remote-exec): Connecting to remote host via SSH...
module.frontend.hcloud_server.server[1] (remote-exec):   Host: 95.216.185.94
module.frontend.hcloud_server.server[1] (remote-exec):   User: root
module.frontend.hcloud_server.server[1] (remote-exec):   Password: false
module.frontend.hcloud_server.server[1] (remote-exec):   Private key: true
module.frontend.hcloud_server.server[1] (remote-exec):   SSH Agent: true
module.frontend.hcloud_server.server[1] (remote-exec):   Checking Host Key: false
module.frontend.hcloud_server.server.1: Still creating... (20s elapsed)
module.frontend.hcloud_server.server.0: Still creating... (20s elapsed)
module.frontend.hcloud_server.server[0] (remote-exec): Connecting to remote host via SSH...
module.frontend.hcloud_server.server[0] (remote-exec):   Host: 95.216.185.25
module.frontend.hcloud_server.server[0] (remote-exec):   User: root
module.frontend.hcloud_server.server[0] (remote-exec):   Password: false
module.frontend.hcloud_server.server[0] (remote-exec):   Private key: true
module.frontend.hcloud_server.server[0] (remote-exec):   SSH Agent: true
module.frontend.hcloud_server.server[0] (remote-exec):   Checking Host Key: false
module.frontend.hcloud_server.server[1] (remote-exec): Connecting to remote host via SSH...
module.frontend.hcloud_server.server[1] (remote-exec):   Host: 95.216.185.94
module.frontend.hcloud_server.server[1] (remote-exec):   User: root
module.frontend.hcloud_server.server[1] (remote-exec):   Password: false
module.frontend.hcloud_server.server[1] (remote-exec):   Private key: true
module.frontend.hcloud_server.server[1] (remote-exec):   SSH Agent: true
module.frontend.hcloud_server.server[1] (remote-exec):   Checking Host Key: false
module.frontend.hcloud_server.server.1: Still creating... (30s elapsed)
module.frontend.hcloud_server.server.0: Still creating... (30s elapsed)
module.frontend.hcloud_server.server[0] (remote-exec): Connecting to remote host via SSH...
module.frontend.hcloud_server.server[0] (remote-exec):   Host: 95.216.185.25
module.frontend.hcloud_server.server[0] (remote-exec):   User: root
module.frontend.hcloud_server.server[0] (remote-exec):   Password: false
module.frontend.hcloud_server.server[0] (remote-exec):   Private key: true
module.frontend.hcloud_server.server[0] (remote-exec):   SSH Agent: true
module.frontend.hcloud_server.server[0] (remote-exec):   Checking Host Key: false
module.frontend.hcloud_server.server[1] (remote-exec): Connecting to remote host via SSH...
module.frontend.hcloud_server.server[1] (remote-exec):   Host: 95.216.185.94
module.frontend.hcloud_server.server[1] (remote-exec):   User: root
module.frontend.hcloud_server.server[1] (remote-exec):   Password: false
module.frontend.hcloud_server.server[1] (remote-exec):   Private key: true
module.frontend.hcloud_server.server[1] (remote-exec):   SSH Agent: true
module.frontend.hcloud_server.server[1] (remote-exec):   Checking Host Key: false
module.frontend.hcloud_server.server[0] (remote-exec): Connecting to remote host via SSH...
module.frontend.hcloud_server.server[0] (remote-exec):   Host: 95.216.185.25
module.frontend.hcloud_server.server[0] (remote-exec):   User: root
module.frontend.hcloud_server.server[0] (remote-exec):   Password: false
module.frontend.hcloud_server.server[0] (remote-exec):   Private key: true
module.frontend.hcloud_server.server[0] (remote-exec):   SSH Agent: true
module.frontend.hcloud_server.server[0] (remote-exec):   Checking Host Key: false
module.frontend.hcloud_server.server[1] (remote-exec): Connecting to remote host via SSH...
module.frontend.hcloud_server.server[1] (remote-exec):   Host: 95.216.185.94
module.frontend.hcloud_server.server[1] (remote-exec):   User: root
module.frontend.hcloud_server.server[1] (remote-exec):   Password: false
module.frontend.hcloud_server.server[1] (remote-exec):   Private key: true
module.frontend.hcloud_server.server[1] (remote-exec):   SSH Agent: true
module.frontend.hcloud_server.server[1] (remote-exec):   Checking Host Key: false
module.frontend.hcloud_server.server[0] (remote-exec): Connected!
module.frontend.hcloud_server.server[1] (remote-exec): Connected!
module.frontend.hcloud_server.server[0] (remote-exec): gift-bro-front01
module.frontend.hcloud_server.server[0] (remote-exec):  18:49:16 up 0 min,  1 user,  load average: 0.68, 0.16, 0.05
module.frontend.hcloud_server.server[0]: Creation complete after 36s (ID: 1883473)
module.frontend.hcloud_server.server[1] (remote-exec): gift-bro-front02
module.frontend.hcloud_server.server[1] (remote-exec):  18:49:17 up 0 min,  1 user,  load average: 0.15, 0.03, 0.01
module.frontend.hcloud_server.server[1]: Creation complete after 36s (ID: 1883474)
module.frontend.hcloud_volume_attachment.data_disk[1]: Creating...
  automount: "" => "true"
  server_id: "" => "1883474"
  volume_id: "" => "1844720"
module.frontend.hcloud_volume_attachment.data_disk[0]: Creating...
  automount: "" => "true"
  server_id: "" => "1883473"
  volume_id: "" => "1844721"
module.frontend.godaddy_domain_record.server_A_record[0]: Creating...
  domain:                     "" => "giftbro.xyz"
  record.#:                   "0" => "1"
  record.1265497963.data:     "" => "95.216.185.25"
  record.1265497963.name:     "" => "gift-bro-front01"
  record.1265497963.priority: "" => "0"
  record.1265497963.ttl:      "" => "600"
  record.1265497963.type:     "" => "A"
module.frontend.godaddy_domain_record.server_A_record[1]: Creating...
  domain:                     "" => "giftbro.xyz"
  record.#:                   "0" => "1"
  record.2951903380.data:     "" => "95.216.185.94"
  record.2951903380.name:     "" => "gift-bro-front02"
  record.2951903380.priority: "" => "0"
  record.2951903380.ttl:      "" => "600"
  record.2951903380.type:     "" => "A"
module.frontend.hcloud_volume_attachment.data_disk[1]: Creation complete after 3s (ID: 1844720)
module.frontend.hcloud_volume_attachment.data_disk[0]: Creation complete after 3s (ID: 1844721)
module.frontend.godaddy_domain_record.server_A_record.0: Still creating... (10s elapsed)
module.frontend.godaddy_domain_record.server_A_record.1: Still creating... (10s elapsed)
module.frontend.godaddy_domain_record.server_A_record[0]: Creation complete after 10s (ID: 286785733)
module.frontend.godaddy_domain_record.server_A_record[1]: Creation complete after 11s (ID: 286785733)

Apply complete! Resources: 8 added, 0 changed, 0 destroyed.

but only one recorad is avialiable
image

also, host command confirms it ))

And after destroying all resources, DNS records still exists.

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

1 participant