Created
September 28, 2018 02:35
-
-
Save djaboxx/c33743432f3aafbf9814bca1051269c6 to your computer and use it in GitHub Desktop.
a simple Terraform Configuration file to launch a VM in OpenStack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable "OS_AUTH_URL" {} | |
variable "OS_PASSWORD" {} | |
variable "OS_TENANT_NAME" {} | |
variable "OS_USERNAME" {} | |
variable "OS_KEYPAIR" {} | |
variable "OPENSTACK_PROVIDER_NET" {} | |
variable "vm_name" {} | |
variable "flavor_name" {} | |
# Configure the OpenStack Provider | |
provider "openstack" { | |
tenant_name = "${var.OS_TENANT_NAME}" | |
user_name = "${var.OS_USERNAME}" | |
password = "${var.OS_PASSWORD}" | |
auth_url = "${var.OS_AUTH_URL}" | |
} | |
### Get image ID for latest version | |
data "openstack_images_image_v2" "Ubuntu1804" { | |
name = "Ubuntu1804-Latest" | |
most_recent = true | |
} | |
### Deploy Ubuntu1804 with only provider network ### | |
resource "openstack_compute_instance_v2" "vm" { | |
name = "${var.vm_name}" | |
flavor_name = "${var.flavor_name}" | |
key_pair = "${var.OS_KEYPAIR}" | |
lifecycle { | |
ignore_changes = "block_device" | |
} | |
block_device { | |
uuid = "${data.openstack_images_image_v2.Ubuntu1804.id}" | |
source_type = "image" | |
volume_size = "${data.openstack_images_image_v2.Ubuntu1804.min_disk_gb}" | |
boot_index = 0 | |
destination_type = "volume" | |
delete_on_termination = true | |
} | |
network { | |
name = "${var.OPENSTACK_PROVIDER_NET}" | |
} | |
} | |
output "ip_address" { | |
value = "${openstack_compute_instance_v2.openstack-Ubuntu1804.access_ip_v4}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment