Created
November 28, 2019 10:15
-
-
Save f4rx/ae5d9a412226e319dbf3e517e0764dcc to your computer and use it in GitHub Desktop.
app.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ################################### | |
| # Create Server | |
| ################################### | |
| resource "openstack_compute_instance_v2" "instance_app" { | |
| name = "app" | |
| flavor_id = "${data.openstack_compute_flavor_v2.flavor_1.id}" | |
| key_pair = "${openstack_compute_keypair_v2.terraform_key.id}" | |
| availability_zone = "${var.az_zone}" | |
| network { | |
| port = "${openstack_networking_port_v2.port_app.id}" | |
| } | |
| block_device { | |
| uuid = "${openstack_blockstorage_volume_v3.volume_app.id}" | |
| source_type = "volume" | |
| destination_type = "volume" | |
| boot_index = 0 | |
| } | |
| vendor_options { | |
| ignore_resize_confirmation = true | |
| } | |
| provisioner "file" { | |
| content = <<-EOT | |
| docker run -d --net=host --name consul \ | |
| -e CONSUL_BIND_INTERFACE=eth0 \ | |
| -e 'CONSUL_ALLOW_PRIVILEGED_PORTS=' \ | |
| consul:1.6 \ | |
| agent -dns-port=53 \ | |
| -recursor=8.8.8.8 \ | |
| -retry-join "provider=os tag_key=consul tag_value=server auth_url=https://api.selvpc.ru/identity/v3 password=${var.user_password} user_name=${var.user_name} project_id=${var.project_id} domain_name=${var.domain_name} region=${var.region}" | |
| # '" | |
| EOT | |
| destination = "/tmp/run_consul.sh" | |
| connection { | |
| type = "ssh" | |
| host = "${openstack_networking_floatingip_v2.floatingip_app.address}" | |
| user = "root" | |
| private_key = "${file("~/.ssh/id_rsa")}" | |
| # agent = true | |
| } | |
| } | |
| provisioner "remote-exec" { | |
| inline = [ | |
| "chmod +x /tmp/run_consul.sh", | |
| "/tmp/run_consul.sh", | |
| ] | |
| connection { | |
| type = "ssh" | |
| host = "${openstack_networking_floatingip_v2.floatingip_app.address}" | |
| user = "root" | |
| private_key = "${file("~/.ssh/id_rsa")}" | |
| # agent = true | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment