Building VM using terraform

173 views
Skip to first unread message

JeezJoon

unread,
Nov 19, 2019, 11:36:44 AM11/19/19
to Terraform
Hello, I am looking for some resources to instruct how to build VM using terraform, Linux CentOs7 any help will be appreciated.

Giovanni Tirloni

unread,
Nov 19, 2019, 12:41:02 PM11/19/19
to terrafo...@googlegroups.com
Do you men a VM image to be deployed somewhere? Check https://packer.io

For terraform, the main website has lots of information.

On Tue, Nov 19, 2019, 13:36 JeezJoon <majid.m...@gmail.com> wrote:
Hello, I am looking for some resources to instruct how to build VM using terraform, Linux CentOs7 any help will be appreciated.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.

GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-too...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/23a26c08-9575-4092-85b9-59f0ebee8b65%40googlegroups.com.

Yaqub Omofoyewa

unread,
Jun 15, 2021, 4:09:58 AM6/15/21
to Terraform

Hi guys, can someone please assist, I want to create a VM attached with an ISO file in my datastore. In my configuration however whenever i tried to assisgn a static IP to the VM then my configuration gives Error: Unsopported arguement.

<<<Just to make sure that I am getting the right answers>>>

I am not using a module, also I am only creating a fresh VM but i need to assign/mention a static IP to the machine while provisioning in my Terraform code just like when using Terraform module (https://registry.terraform.io/modules/Terraform-VMWare-Modules/vm/vsphere/latest).

provider "vsphere" { user = var.vsphere_user password = var.vsphere_password vsphere_server = var.vsphere_server # If you have a self-signed cert allow_unverified_ssl = true } data "vsphere_datacenter" "dc" { name = "dc1" } data "vsphere_datastore" "datastore" { name = "datastore1" datacenter_id = data.vsphere_datacenter.dc.id } data "vsphere_resource_pool" "pool" { name = "cluster1/Resources" datacenter_id = data.vsphere_datacenter.dc.id } data "vsphere_network" "network" { name = "public" datacenter_id = data.vsphere_datacenter.dc.id } resource "vsphere_virtual_machine" "vm" { name = "terraform-test" resource_pool_id = data.vsphere_resource_pool.pool.id datastore_id = data.vsphere_datastore.datastore.id num_cpus = 2 memory = 1024 guest_id = "other3xLinux64Guest" network_interface { network_id = data.vsphere_network.network.id } disk { label = "disk0" size = 20 } }

This template above from Terraform seems not to solve my problem because there was no static IP assigned. https://registry.terraform.io/providers/hashicorp/vsphere/latest/docs

:::same data source::: 

 resource "vsphere_virtual_machine" "vm" { #count = 1 name = "terraform-test" resource_pool_id = data.vsphere_resource_pool.pool.id host_system_id = data.vsphere_host.host.id datastore_id = data.vsphere_datastore.datastore.id folder = "known-DC" wait_for_guest_net_timeout = 0 wait_for_guest_ip_timeout = 0 num_cpus = 2 memory = 4096 guest_id = "centos7_64Guest" network_interface { ipv4_address = "192.168.2.18" ipv4_netmask = 24 dns_server_list = ["192.168.2.10", "8.8.8.8"] network_id = data.vsphere_network.network.id } cdrom { datastore_id = data.vsphere_datastore.datastore.id path = "CentOS-8.iso" } disk { label = "disk0" size = 20 } }

As you can see, an ISO file is attached above. So, I want something like that code above. Do i need to declare a new data for the network interface??

In such that whenever i want to create a VM, I can assign a static IP address to the new VM.

I will appreciate this.

many thanks

Alexandra Freeman

unread,
Jun 21, 2021, 10:32:04 AM6/21/21
to Terraform
Hello and thank you for your question!
On June 3, 2019 HashiCorp launched Discuss, a forum to facilitate dialogue within the HashiCorp community. This format allows answers to be more readily searched and indexed, making it easier to find answers to existing questions and to share knowledge with each other. Please direct all questions and conversations to the discussion forum. We look forward to collaborating with you there!

Cheers!

Yaqub Omofoyewa

unread,
Jun 22, 2021, 5:32:44 PM6/22/21
to Terraform
Thank you . I now joined the disccsion forum and besides I already cloned the VM instead!

many thanks
Reply all
Reply to author
Forward
0 new messages