Skip to content

Instantly share code, notes, and snippets.

@f4rx
Last active April 22, 2022 19:39
Show Gist options
  • Save f4rx/7704f5663f026fde2feb9668d788d6c4 to your computer and use it in GitHub Desktop.
Save f4rx/7704f5663f026fde2feb9668d788d6c4 to your computer and use it in GitHub Desktop.
server2.tf
###################################
# Create port
###################################
resource "openstack_networking_port_v2" "port_2" {
name = "node-eth0"
network_id = openstack_networking_network_v2.network_1.id
fixed_ip {
subnet_id = openstack_networking_subnet_v2.subnet_1.id
}
}
###################################
# Create Volume/Disk
###################################
resource "openstack_blockstorage_volume_v3" "volume_2" {
name = "volume-for-node"
size = var.hdd_size
image_id = data.openstack_images_image_v2.ubuntu.id
volume_type = var.volume_type
availability_zone = var.az_zone
enable_online_resize = true
lifecycle {
ignore_changes = [image_id]
}
}
###################################
# Create Server
###################################
resource "openstack_compute_instance_v2" "instance_2" {
name = "node"
flavor_id = openstack_compute_flavor_v2.flavor-node.id
key_pair = openstack_compute_keypair_v2.terraform_key.id
availability_zone = var.az_zone
network {
port = openstack_networking_port_v2.port_2.id
}
block_device {
uuid = openstack_blockstorage_volume_v3.volume_2.id
source_type = "volume"
destination_type = "volume"
boot_index = 0
}
vendor_options {
ignore_resize_confirmation = true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment