Skip to content
Snippets Groups Projects
Commit d3390323 authored by Eesaan Atluri's avatar Eesaan Atluri
Browse files

Changes Register new nodes in WW DB. Ops provisioning.

1.Add depends on clause on new nodes so that we can push the
required attributes (IP and MAC) from terraform into the ansible.

2.Use extra-vars arg of ansible to pass the terraform attributes.

3.Add code for port creation and attach compute node iface to it.
parent cb440da9
No related branches found
No related tags found
No related merge requests found
...@@ -77,6 +77,12 @@ resource "openstack_compute_instance_v2" "ohpc" { ...@@ -77,6 +77,12 @@ resource "openstack_compute_instance_v2" "ohpc" {
resource "openstack_compute_floatingip_associate_v2" "ohpc" { resource "openstack_compute_floatingip_associate_v2" "ohpc" {
floating_ip = openstack_networking_floatingip_v2.ohpc_ip.address floating_ip = openstack_networking_floatingip_v2.ohpc_ip.address
instance_id = openstack_compute_instance_v2.ohpc.id instance_id = openstack_compute_instance_v2.ohpc.id
depends_on = [openstack_compute_instance_v2.c0, openstack_networking_port_v2.port_c0, openstack_compute_instance_v2.ood]
#compute-ip = openstack_compute_instance_v2.c0.clusternet.fixed_ip_v4
#compute-mac = openstack_networking_port_v2.port_c0.mac_address
#ood-ip = openstack_compute_instance_v2.ood.clusternet.fixed_ip_v4
#ood-mac = openstack_compute_instance_v2.ood.clusternet.mac
# defines ssh connection # defines ssh connection
connection { connection {
...@@ -92,9 +98,26 @@ resource "openstack_compute_floatingip_associate_v2" "ohpc" { ...@@ -92,9 +98,26 @@ resource "openstack_compute_floatingip_associate_v2" "ohpc" {
} }
############# Included next two blocks to make testing easy. Will be removed. #################
provisioner "remote-exec" {
inline = [
"sudo mkdir -p /CRI_XCBC2 && sudo chown centos: /CRI_XCBC2",
]
}
# moves CRI_XCBC file into directory made above
provisioner "file" {
source = "CRI_XCBC/"
destination = "/CRI_XCBC2/"
}
################################# End of the testing blocks ###################################
provisioner "remote-exec" { provisioner "remote-exec" {
inline = [ inline = [
"sudo ansible-playbook -c local -i /CRI_XCBC/hosts -l `hostname -s` /CRI_XCBC/site-ops.yaml -b" "sudo ansible-playbook -c local -i /CRI_XCBC2/hosts -l `hostname -s` -e \" compute_mac=${openstack_networking_port_v2.port_c0.mac_address} compute_ip=${openstack_networking_port_v2.port_c0.all_fixed_ips[0]} \" /CRI_XCBC2/site-ops.yaml -b"
] ]
} }
} }
...@@ -136,9 +159,16 @@ resource "openstack_compute_floatingip_associate_v2" "ood" { ...@@ -136,9 +159,16 @@ resource "openstack_compute_floatingip_associate_v2" "ood" {
} }
} }
resource "openstack_networking_port_v2" "port_c0" {
depends_on = ["openstack_networking_subnet_v2.internal_subnet",]
name = "port_c0"
network_id = "${openstack_networking_network_v2.internal_net.id}"
admin_state_up = "true"
}
# creates compute node # creates compute node
resource "openstack_compute_instance_v2" "c0" { resource "openstack_compute_instance_v2" "c0" {
depends_on = [openstack_networking_subnet_v2.internal_subnet] #depends_on = [openstack_networking_subnet_v2.internal_subnet]
name = "c${count.index}" name = "c${count.index}"
image_name = var.image_compute image_name = var.image_compute
flavor_name = var.flavor flavor_name = var.flavor
...@@ -148,6 +178,6 @@ resource "openstack_compute_instance_v2" "c0" { ...@@ -148,6 +178,6 @@ resource "openstack_compute_instance_v2" "c0" {
# defines the networks of the instance # defines the networks of the instance
network { network {
name = var.internal-net port = "${openstack_networking_port_v2.port_c0.id}"
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment