Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • rrand11/terraform-openstack
  • louistw/terraform-openstack
  • chirag24/terraform-openstack
  • mmoo97/terraform-openstack
  • jpr/terraform-openstack
  • ravi89/terraform-openstack
  • noe121/terraform-openstack
  • ishan747/terraform-openstack
  • clint93/terraform-openstack
  • ravi89/terraform_openstack
  • krish94/terraform-openstack
  • rc/terraform-openstack
12 results
Show changes
Commits on Source (27)
Subproject commit 1d7a787a562130d8b96d1b85d087c4a3ecc34f41
Subproject commit 89297776283f025d8b51e4f83dc7ac78f3ada92b
......@@ -20,7 +20,7 @@ resource "openstack_networking_subnet_v2" "external_subnet" {
network_id = openstack_networking_network_v2.external_network.id
cidr = "192.168.100.0/24"
ip_version = 4
dns_nameservers = ["8.8.8.8"]
dns_nameservers = ["172.20.0.137", "172.20.0.3", "8.8.8.8"]
enable_dhcp = var.enable_dhcp
}
......@@ -46,4 +46,4 @@ output "external_subnet_id" {
output "router_id" {
value = openstack_networking_router_v2.router.id
}
\ No newline at end of file
}
......@@ -65,6 +65,7 @@ module "create-ohpc-instance" {
key_pair = "${module.import-keypair.keypair_name}"
external_network = var.external_network
internal_network = var.internal_network
internal_ip = var.ohpc_private_ip
floating_ip_ohpc = "${module.floating-ip-address.ohpc_address}"
host_prefix = var.host_prefix
ohpc_user = var.ohpc_user
......@@ -81,6 +82,7 @@ module "create-ood-instance" {
flavor = var.flavor
key_pair = "${module.import-keypair.keypair_name}"
internal_network = var.internal_network
internal_ip = var.ood_private_ip
external_network = var.external_network
floating_ip_ood = "${module.floating-ip-address.ood_address}"
host_prefix = var.host_prefix
......@@ -108,4 +110,33 @@ output "ohpc-ssh_host" {
# calls the outputs defined in the ood-instance module
output "ood-ssh_host" {
value = "${module.create-ood-instance.ssh_host}"
}
\ No newline at end of file
}
# compute node and ood post provision
# use single null_resource for serial provisioner runs to avoid race conditions
# that lead to inconsistent deploy successes.
resource "null_resource" "ops" {
triggers = {
ohpc_instance = module.create-ohpc-instance.id
compute_instances = join(",", module.nodes.id)
}
connection {
host = module.create-ohpc-instance.ssh_host
user = var.ohpc_user
private_key = file(var.ssh_private_key)
}
#
# explore feature for simply cluster provisioning
# Ignore all provisioners for non-ohpc cluster
#
# provisioners run on cluster master(node) node
provisioner "remote-exec" {
inline = [
for node, net in module.nodes.network:
"echo DEBUG: empty provisioner action: ${node}"]
}
}
......@@ -10,20 +10,41 @@ variable "key_pair" {type = "string"}
variable "compute_node_count" { }
variable "internal_network" {}
data "openstack_images_image_v2" "compute" {
name = var.image_compute
most_recent = true
}
# creates compute node
resource "openstack_compute_instance_v2" "c0" {
resource "openstack_compute_instance_v2" "compute" {
depends_on = [var.internal_subnet_id]
name = "c${count.index}"
image_name = var.image_compute
image_id = data.openstack_images_image_v2.compute.id
flavor_name = var.flavor
key_pair = var.key_pair
security_groups = ["default"]
count = var.compute_node_count
user_data = <<-EOF
#cloud-config
runcmd:
- [ bash, -xc, 'echo DEBUG: empty user_data var: add post instantiation steps here' ]
EOF
# defines the networks of the instance
network {
name = var.internal_network
}
}
\ No newline at end of file
}
# output
output "id" {
value = openstack_compute_instance_v2.compute.*.id
}
output "image_id" {
value = data.openstack_images_image_v2.compute.id
}
output "network" {
value = zipmap(openstack_compute_instance_v2.compute.*.name, openstack_compute_instance_v2.compute.*.network)
}
......@@ -9,6 +9,7 @@ variable "flavor" {}
variable "key_pair" {type = "string"}
variable "internal_network" {}
variable "internal_ip" {}
variable "external_network" {}
# is created in floating-ip module and called in root module
......@@ -27,6 +28,15 @@ resource "openstack_compute_instance_v2" "ohpc" {
flavor_name = var.flavor
key_pair = var.key_pair
security_groups = ["default"]
user_data = <<-EOF
#cloud-config
write_files:
- content: |
10.1.1.10 ohpc ohpc.novalocal
owner: centos:centos
path: /etc/hosts
permissions: 0644
EOF
# defines the networks of the instance
network {
......@@ -34,6 +44,7 @@ resource "openstack_compute_instance_v2" "ohpc" {
}
network {
name = var.internal_network
fixed_ip_v4 = var.internal_ip
}
}
......@@ -50,6 +61,10 @@ resource "openstack_compute_floatingip_associate_v2" "ohpc" {
}
}
output "id" {
value = openstack_compute_instance_v2.ohpc.id
}
output "ssh_host" {
value = format(var.host_prefix,element(split(".", var.floating_ip_ohpc),3,),)
}
\ No newline at end of file
}
......@@ -9,6 +9,7 @@ variable "flavor" {}
variable "key_pair" {type = "string"}
variable "internal_network" {}
variable "internal_ip" {}
variable "external_network" {}
# is created in floating-ip module and called in root module
......@@ -27,6 +28,12 @@ resource "openstack_compute_instance_v2" "ood" {
flavor_name = var.flavor
key_pair = var.key_pair
security_groups = ["default"]
user_data = <<-EOF
#cloud-config
runcmd:
- [ bash, -xc, 'echo DEBUG: empty user_data var: add post instantiation steps here' ]
EOF
# defines the networks of the instance
network {
......@@ -34,6 +41,7 @@ resource "openstack_compute_instance_v2" "ood" {
}
network {
name = var.internal_network
fixed_ip_v4 = var.internal_ip
}
}
......@@ -51,7 +59,12 @@ resource "openstack_compute_floatingip_associate_v2" "ood" {
}
output "id" {
value = openstack_compute_instance_v2.ood.id
}
output "ssh_host"{
value = format(var.host_prefix,element(split(".", var.floating_ip_ood),3,),)
}
\ No newline at end of file
}
output "network" {
value = openstack_compute_instance_v2.ood.network
}
......@@ -14,9 +14,11 @@ variable "ssh_public_key" {default = "~/.ssh/id_rsa.pub"}
# variables for instance modules
variable "ohpc_instance_name" {default = "ohpc"}
variable "ohpc_private_ip" {default = "10.1.1.10"}
variable "ood_instance_name" { default = "ood"}
variable "image_ohpc" {default = "CentOS-7-x86_64-GenericCloud-1905"}
variable "image_ood" {default = "CentOS-7-x86_64-GenericCloud-1905"}
variable "ood_private_ip" {default = "10.1.1.11"}
variable "flavor" {default = "m1.medium"}
variable "internal_network" {default = "clusternet"}
variable "external_network" {default = "dmznet"}
......