diff --git a/main.tf b/main.tf index 5515f4f7d6c3ff298bdc39dadb1803f7ea855546..80adfa92d8103c00e77bc80cd240034415718ec3 100644 --- a/main.tf +++ b/main.tf @@ -1,10 +1,14 @@ +resource "openstack_compute_keypair_v2" "test-keypair" { + name = "my-keypair" + public_key = "${file("~/.ssh/id_rsa.pub")}" +} #local variable for ssh connect to ohpc locals { connection = { host = "${format("164.111.161.%s", element(split(".", openstack_networking_floatingip_v2.ip_pool.address),3))}" user = "centos" - private_key = "${file(var.ssh_key)}" + private_key = "${file("~/.ssh/id_rsa")}" } } @@ -63,7 +67,7 @@ depends_on = ["openstack_networking_subnet_v2.dmzsubnet"] name = "ohpc" image_name = "${var.image}" flavor_name = "${var.flavor}" - key_pair = "${file(var.ssh_key)}" + key_pair = "${openstack_compute_keypair_v2.openstack.key_name}" security_groups = ["default"] # defines the networks of the instance @@ -84,7 +88,7 @@ resource "openstack_compute_floatingip_associate_v2" "ohpc" { connection { host = "${format("164.111.161.%s", element(split(".", openstack_networking_floatingip_v2.ip_pool.address),3))}" user = "centos" - private_key = "${file(var.ssh_key)}" + private_key = "${file("~/.ssh/id_rsa")}" } inline = [ @@ -104,7 +108,7 @@ resource "openstack_compute_floatingip_associate_v2" "ohpc" { host = "${format("164.111.161.%s", element(split(".", openstack_networking_floatingip_v2.ip_pool.address),3))}" #host = "${openstack_networking_floatingip_v2.terraform.address}" user = "centos" - private_key = "${file(var.ssh_key)}" + private_key = "${file("~/.ssh/id_rsa")}" } } @@ -113,7 +117,7 @@ resource "openstack_compute_floatingip_associate_v2" "ohpc" { host = "${format("164.111.161.%s", element(split(".", openstack_networking_floatingip_v2.ip_pool.address),3))}" #host = "${openstack_networking_floatingip_v2.ohpc.address}" user = "centos" - private_key = "${file(var.ssh_key)}" + private_key = "${file("~/.ssh/id_rsa")}" } inline = [ "sudo ansible-playbook -c local -i /CRI_XCBC/hosts -l `hostname -s` /CRI_XCBC/site.yaml -b"