Commit 2cc174a6 authored by Ryan Randles Jones's avatar Ryan Randles Jones
Browse files

Add new file

parent 9754be2a
# defines where floating ip will come from using variable from vars.tf
resource "openstack_networking_floatingip_v2" "ohpc" {
pool = "${var.pool}"
}
# creates details for the instance using variables defined in vars.tf and resource for security groups
resource "openstack_compute_instance_v2" "ohpc" {
name = "ohpc"
image_name = "${var.image}"
flavor_name = "${var.flavor}"
key_pair = "${var.key_pair}"
security_groups = ["default"]
# defines the networks of the instance
network {
name = "dmznet"
}
network {
name = "clusternet"
}
}
# associates floating ip with the instance
resource "openstack_compute_floatingip_associate_v2" "ohpc" {
floating_ip = "${openstack_networking_floatingip_v2.ohpc.address}"
instance_id = "${openstack_compute_instance_v2.ohpc.id}"
provisioner "remote-exec" {
connection {
host = "${format("164.111.161.%s", element(split(".", openstack_networking_floatingip_v2.ohpc.address),3))}"
#host = "${openstack_networking_floatingip_v2.ohpc.address}"
user = "centos"
private_key = "${file(var.ssh_key_private)}"
}
inline = [
"sudo mkdir -p /CRI_XCBC && sudo chown centos: /CRI_XCBC",
"sudo yum install -y epel-release",
"sudo yum install -y ansible git vim bash-completion",
"sudo yum install -y NetworkManager",
"sudo systemctl restart NetworkManager",
"sudo nmcli con mod 'Wired connection 1' connection.id 'eth1'"
]
}
provisioner "file" {
source = "CRI_XCBC/"
destination = "/CRI_XCBC/"
connection {
host = "${format("164.111.161.%s", element(split(".", openstack_networking_floatingip_v2.ohpc.address),3))}"
#host = "${openstack_networking_floatingip_v2.terraform.address}"
user = "centos"
private_key = "${file(var.ssh_key_private)}"
}
}
provisioner "remote-exec" {
connection {
host = "${format("164.111.161.%s", element(split(".", openstack_networking_floatingip_v2.ohpc.address),3))}"
#host = "${openstack_networking_floatingip_v2.ohpc.address}"
user = "centos"
private_key = "${file(var.ssh_key_private)}"
}
inline = [
"sudo ansible-playbook -c local -i /CRI_XCBC/hosts -l ohpc /CRI_XCBC/site.yaml -b"
]
}
}
# creates details for the instance using variables defined in vars.tf
resource "openstack_compute_instance_v2" "ohpc" {
name = "ohpc"
image_name = "${var.image}"
flavor_name = "${var.flavor}"
key_pair = "${var.key_pair}"
security_groups = ["default"]
# defines the networks of the instance
network {
name = "dmznet"
}
network {
name = "clusternet"
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment