Skip to content

Commit f60fa00

Browse files
Merge pull request #10 from Satak/fix-documentation
Documentation fix, wait_for vars, var typing fix
2 parents 4fdfff4 + 278213a commit f60fa00

File tree

8 files changed

+129
-106
lines changed

8 files changed

+129
-106
lines changed

README.md

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
11
# Terraform vSphere Module (:star2: All new features)
22

3-
For Virtual Machine Provisioning with (Linux/Windows) customization. Thanks to the new enhancements introduced in Terraform v0.12.6 this module include most of the advance features that are available in the resource `vsphere_virtual_machine`.
3+
For Virtual Machine Provisioning with (Linux/Windows) customization. Thanks to the new enhancements introduced in Terraform v0.12.6 this module include most of the advance features that are available in the resource `vsphere_virtual_machine`.
44

5-
:warning: The new version of this module only works with terraform version 0.12.6 and above :warning:
5+
:warning: The new version of this module only works with terraform version 0.12.6 and above :warning:
66

77
> This module now replace the functionality of the following modules:
8-
> * [`Terraform-VMWare-Modules-vm2nic`](https://registry.terraform.io/modules/Terraform-VMWare-Modules/vm2nic/vsphere/0.1.0)
9-
> * [`Terraform-VMWare-Modules-vm3nic`](https://registry.terraform.io/modules/Terraform-VMWare-Modules/vm3nic/vsphere/0.1.0)
8+
>
9+
> - [`Terraform-VMWare-Modules-vm2nic`](https://registry.terraform.io/modules/Terraform-VMWare-Modules/vm2nic/vsphere/0.1.0)
10+
> - [`Terraform-VMWare-Modules-vm3nic`](https://registry.terraform.io/modules/Terraform-VMWare-Modules/vm3nic/vsphere/0.1.0)
1011
1112
## Deploys (Single/Multiple) Virtual Machines to your vSphere environment
1213

1314
This Terraform module deploys single or multiple virtual machines of type (Linux/Windows) with following features:
1415

15-
* Ability to specify Linux or Windows VM customization.
16-
* Ability to add extra data disk (up to 15) to the VM.
17-
* Ability to deploy Multiple instances.
18-
* Ability to set IP and Gateway configuration for the VM.
19-
* Ability to add multiple network cards for the VM
20-
* Ability to choose vSphere resource pool or fall back to Cluster/ESXi root resource pool.
21-
* Ability to deploy Windows images to WorkGroup or Domain.
22-
* Ability to output VM names and IPs per module.
23-
* Ability assign tags and custom variables.
24-
* Ability to configure advance features for the vm.
25-
* Ability to deploy either a datastore or a datastore cluster.
26-
* Ability to enable cpu and memory hot plug features for the VM.
16+
- Ability to specify Linux or Windows VM customization.
17+
- Ability to add extra data disk (up to 15) to the VM.
18+
- Ability to deploy Multiple instances.
19+
- Ability to set IP and Gateway configuration for the VM.
20+
- Ability to add multiple network cards for the VM
21+
- Ability to choose vSphere resource pool or fall back to Cluster/ESXi root resource pool.
22+
- Ability to deploy Windows images to WorkGroup or Domain.
23+
- Ability to output VM names and IPs per module.
24+
- Ability assign tags and custom variables.
25+
- Ability to configure advance features for the vm.
26+
- Ability to deploy either a datastore or a datastore cluster.
27+
- Ability to enable cpu and memory hot plug features for the VM.
2728

2829
> Note: For module to work it needs number of required variables corresponding to an existing resources in vSphere. Please refer to variable section for the list of required variables.
2930
@@ -36,30 +37,30 @@ You can also download the entire module and use your own predefined variables to
3637
```hcl
3738
module "example-server-linuxvm" {
3839
source = "Terraform-VMWare-Modules/vm/vsphere"
39-
version = "1.0.0"
40+
version = "1.0.2"
4041
vmtemp = "TemplateName"
4142
instances = 1
4243
vmname = "example-server-windows"
4344
vmrp = "esxi/Resources"
44-
network_cards = ["Name of the POrt Group in vSphere"]
45+
network_cards = ["Name of the Port Group in vSphere"]
4546
ipv4 = {
46-
"Name of the POrt Group in vSphere" = ["10.0.0.1"] # To use DHCP create Empty list for each instance
47+
"Name of the Port Group in vSphere" = ["10.0.0.1"] # To use DHCP create Empty list for each instance
4748
}
4849
dc = "Datacenter"
4950
datastore = "Data Store name(use ds_cluster for datastore cluster)"
5051
}
5152
5253
module "example-server-windowsvm" {
5354
source = "Terraform-VMWare-Modules/vm/vsphere"
54-
version = "1.0.0"
55+
version = "1.0.2"
5556
vmtemp = "TemplateName"
5657
is_windows_image = "true"
5758
instances = 1
5859
vmname = "example-server-windows"
5960
vmrp = "esxi/Resources"
60-
network_cards = ["Name of the POrt Group in vSphere"]
61+
network_cards = ["Name of the Port Group in vSphere"]
6162
ipv4 = {
62-
"Name of the POrt Group in vSphere" = ["10.0.0.1"] # To use DHCP create Empty list for each instance
63+
"Name of the Port Group in vSphere" = ["10.0.0.1"] # To use DHCP create Empty list for each instance
6364
}
6465
dc = "Datacenter"
6566
datastore = "Data Store name(use ds_cluster for datastore cluster)"
@@ -74,22 +75,22 @@ There are number of switches defined in the module, where you can use to enable
7475

7576
### Main Feature Switches
7677

77-
* You can use `is_windows_image = "true"` to set the customization type to Windows (By default it is set to Linux customization)
78-
* You can use `data_disk_size_gb = [20,30]` to add one additional disk (Supported in both Linux and Windows deployment)
79-
* Above switch will create two additional disk of capacity 10 and 30gb for the VM.
80-
* You can include `thin_provisioned` switch to define disk type for each additional disk.
81-
* You can use `windomain = "somedomain.com"` to join a windows server to AD domain.
82-
* Requires following additional variables
83-
* `domainuser` Domain account with necessary privileges to join a computer to the domain.
84-
* `domainpass` Domain user password.
85-
* `is_windows_image` needs to be set to `true` to force the module to use Windows customization.
78+
- You can use `is_windows_image = "true"` to set the customization type to Windows (By default it is set to Linux customization)
79+
- You can use `data_disk_size_gb = [20,30]` to add additional data disks (Supported in both Linux and Windows deployment)
80+
- Above switch will create two additional disk of capacity 10 and 30gb for the VM.
81+
- You can include `thin_provisioned` switch to define disk type for each additional disk.
82+
- You can use `windomain = "somedomain.com"` to join a windows server to AD domain.
83+
- Requires following additional variables
84+
- `domainuser` Domain account with necessary privileges to join a computer to the domain.
85+
- `domainpass` Domain user password.
86+
- `is_windows_image` needs to be set to `true` to force the module to use Windows customization.
8687

8788
Below is an example of windows deployment with some of the available feature sets.
8889

8990
```hcl
9091
module "example-server-windowsvm-advanced" {
9192
source = "Terraform-VMWare-Modules/vm/vsphere"
92-
version = "1.0.0"
93+
version = "1.0.2"
9394
dc = "Datacenter"
9495
vmrp = "cluster/Resources" #Works with ESXi/Resources
9596
vmfolder = "Cattle"
@@ -103,7 +104,7 @@ module "example-server-windowsvm-advanced" {
103104
memory_hot_add_enabled = "true"
104105
vmname = "AdvancedVM"
105106
vmdomain = "somedomain.com"
106-
network_cards = ["VM Network", "test-netwrok"] #Assign multiple cards
107+
network_cards = ["VM Network", "test-network"] #Assign multiple cards
107108
ipv4submask = ["24", "8"]
108109
ipv4 = { #assign IPs per card
109110
"VM Network" = ["192.168.0.4", ""] // Here the first instance will use Static Ip and Second DHCP
@@ -119,7 +120,7 @@ module "example-server-windowsvm-advanced" {
119120
}
120121
enable_disk_uuid = "true"
121122
auto_logon = "true"
122-
run_once = ["command01", "command02"]
123+
run_once = ["command01", "command02"] // You can also run Powershell commands
123124
orgname = "Terraform-Module"
124125
workgroup = "Module-Test"
125126
is_windows_image = "true"
@@ -143,4 +144,4 @@ Originally created by [Arman Keyoumarsi](https://github.com/Arman-Keyoumarsi)
143144

144145
## License
145146

146-
[MIT](LICENSE)
147+
[MIT](LICENSE)

examples/linux/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@ Following example contains the bare minimum options to be configured for the Lin
1313
```hcl
1414
module "example-server-linuxvm" {
1515
source = "Terraform-VMWare-Modules/vm/vsphere"
16-
version = "1.0.0"
16+
version = "1.0.2"
1717
vmtemp = "TemplateName"
1818
instances = 1
1919
vmname = "example-server-windows"
20-
vmrp = "esxi/Resources"
21-
network_cards = ["Name of the POrt Group in vSphere"]
20+
vmrp = "esxi/Resources"
21+
network_cards = ["Name of the Port Group in vSphere"]
2222
ipv4 = {
23-
"Name of the POrt Group in vSphere" = ["10.0.0.1"] # To use DHCP create Empty list for each instance
23+
"Name of the Port Group in vSphere" = ["10.0.0.1"] # To use DHCP create Empty list for each instance
2424
}
2525
dc = "Datacenter"
26-
datastore = "Data Store name(use ds_cluster for datastore cluster)"
26+
datastore = "Data Store name(use ds_cluster for datastore cluster)"
2727
}
2828
```
2929

30-
### Example of Advanced Linux VM Customization
30+
### Example of Advanced Linux VM Customization
3131

3232
Below example will deploy 2 instance of a virtual machine from a linux template. The virtual machines are configured to use 2 network cards with 2 additional disk.
3333

@@ -36,7 +36,7 @@ Below example will deploy 2 instance of a virtual machine from a linux template.
3636
```hcl
3737
module "example-server-linuxvm-withdatadisk" {
3838
source = "Terraform-VMWare-Modules/vm/vsphere"
39-
version = "1.0.0"
39+
version = "1.0.2"
4040
dc = "Datacenter"
4141
vmrp = "cluster/Resources"
4242
vmfolder = "Cattle"
@@ -50,7 +50,7 @@ module "example-server-linuxvm-withdatadisk" {
5050
memory_hot_add_enabled = "true"
5151
vmname = "AdvancedVM"
5252
vmdomain = "somedomain.com"
53-
network_cards = ["VM Network", "test-netwrok"]
53+
network_cards = ["VM Network", "test-network"]
5454
ipv4submask = ["24", "8"]
5555
ipv4 = {
5656
"VM Network" = ["192.168.0.4", ""] // Here the first instance will use Static Ip and Second set to DHCP
@@ -73,4 +73,4 @@ Originally created by [Arman Keyoumarsi](https://github.com/Arman-Keyoumarsi)
7373

7474
## License
7575

76-
[MIT](LICENSE)
76+
[MIT](LICENSE)

examples/linux/main.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
// Simple Linux VM deployment
22
module "example-server-linuxvm" {
33
source = "Terraform-VMWare-Modules/vm/vsphere"
4-
version = "1.0.0"
4+
version = "1.0.2"
55
vmtemp = "TemplateName"
66
instances = 1
77
vmname = "example-server-windows"
88
vmrp = "esxi/Resources"
9-
network_cards = ["Name of the POrt Group in vSphere"]
9+
network_cards = ["Name of the Port Group in vSphere"]
1010
ipv4 = {
11-
"Name of the POrt Group in vSphere" = ["10.0.0.1"] # To use DHCP create Empty list for each instance
11+
"Name of the Port Group in vSphere" = ["10.0.0.1"] # To use DHCP create empty string for each instance
1212
}
1313
dc = "Datacenter"
1414
datastore = "Data Store name(use ds_cluster for datastore cluster)"
1515
}
1616
// Example of Linux VM with more Advanced Features
1717
module "example-server-linuxvm-advanced" {
1818
source = "Terraform-VMWare-Modules/vm/vsphere"
19-
version = "1.0.0"
19+
version = "1.0.2"
2020
dc = "Datacenter"
2121
vmrp = "cluster/Resources"
2222
vmfolder = "Cattle"
@@ -30,13 +30,13 @@ module "example-server-linuxvm-advanced" {
3030
memory_hot_add_enabled = "true"
3131
vmname = "AdvancedVM"
3232
vmdomain = "somedomain.com"
33-
network_cards = ["VM Network", "test-netwrok"]
33+
network_cards = ["VM Network", "test-network"]
3434
ipv4submask = ["24", "8"]
3535
ipv4 = {
3636
"VM Network" = ["192.168.0.4", ""] // Here the first instance will use Static Ip and Second set to DHCP
3737
"test" = ["", "192.168.0.3"]
3838
}
39-
data_disk_size_gb = [10, 5] // Aditional Disk to be used
39+
data_disk_size_gb = [10, 5] // Aditional Disks to be used
4040
thin_provisioned = ["true", "false"]
4141
vmdns = ["192.168.0.2", "192.168.0.1"]
4242
vmgateway = "192.168.0.1"

examples/windows/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ Following example contains the bare minimum options to be configured for the Win
1313
```hcl
1414
module "example-server-windowsvm-withdatadisk" {
1515
source = "Terraform-VMWare-Modules/vm/vsphere"
16-
version = "1.0.0"
16+
version = "1.0.2"
1717
vmtemp = "TemplateName"
1818
instances = 1
1919
vmname = "example-server-windows"
2020
vmrp = "esxi/Resources"
21-
network_cards = ["Name of the POrt Group in vSphere"]
21+
network_cards = ["Name of the Port Group in vSphere"]
2222
ipv4 = {
23-
"Name of the POrt Group in vSphere" = ["10.0.0.1"] # To use DHCP create Empty list for each instance
23+
"Name of the Port Group in vSphere" = ["10.0.0.1"] # To use DHCP create Empty list for each instance
2424
}
2525
dc = "Datacenter"
2626
datastore = "Data Store name(use ds_cluster for datastore cluster)"
@@ -32,7 +32,7 @@ module "example-server-windowsvm-withdatadisk" {
3232
```hcl
3333
module "example-server-windowsvm-advanced" {
3434
source = "Terraform-VMWare-Modules/vm/vsphere"
35-
version = "1.0.0"
35+
version = "1.0.2"
3636
dc = "Datacenter"
3737
vmrp = "cluster/Resources"
3838
vmfolder = "Cattle"
@@ -52,7 +52,7 @@ module "example-server-windowsvm-advanced" {
5252
"VM Network" = ["192.168.0.4", ""] // Here the first instance will use Static Ip and Second DHCP
5353
"test" = ["", "192.168.0.3"]
5454
}
55-
data_disk_size_gb = [10, 5] // Aditional Disk to be used
55+
data_disk_size_gb = [10, 5] // Aditional Disks to be used
5656
thin_provisioned = ["true", "false"]
5757
vmdns = ["192.168.0.2", "192.168.0.1"]
5858
vmgateway = "192.168.0.1"
@@ -62,11 +62,11 @@ module "example-server-windowsvm-advanced" {
6262
}
6363
enable_disk_uuid = "true"
6464
auto_logon = "true"
65-
run_once = ["mkdir c:\\admin", "echo runonce-test >> c:\\admin\\logs.txt"]
65+
run_once = ["mkdir c:\\admin", "echo runonce-test >> c:\\admin\\logs.txt", "powershell.exe \"New-Item C:\\test.txt\""]
6666
orgname = "Terraform-Module"
6767
workgroup = "Module-Test"
6868
is_windows_image = "true"
69-
firmware = "efi"
69+
firmware = "efi"
7070
local_adminpass = "Password@Strong"
7171
}
7272
```
@@ -77,4 +77,4 @@ Originally created by [Arman Keyoumarsi](https://github.com/Arman-Keyoumarsi)
7777

7878
## License
7979

80-
[MIT](LICENSE)
80+
[MIT](LICENSE)

examples/windows/main.tf

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
11
// Example of basic Windows VM
22
module "example-server-windowsvm-withdatadisk" {
33
source = "Terraform-VMWare-Modules/vm/vsphere"
4-
version = "1.0.0"
4+
version = "1.0.2"
55
vmtemp = "TemplateName"
66
is_windows_image = "true"
77
instances = 1
88
vmname = "example-server-windows"
99
vmrp = "esxi/Resources"
10-
network_cards = ["Name of the POrt Group in vSphere"]
10+
network_cards = ["Name of the Port Group in vSphere"]
1111
ipv4 = {
12-
"Name of the POrt Group in vSphere" = ["10.0.0.1"] # To use DHCP create Empty list for each instance
12+
"Name of the Port Group in vSphere" = ["10.0.0.1"] # To use DHCP create empty string for each instance
1313
}
1414
dc = "Datacenter"
1515
datastore = "Data Store name(use ds_cluster for datastore cluster)"
1616
}
1717
// Example of basic Windows VM joined to the domain
1818
module "example-server-windowsvm-withdatadisk" {
19-
source = "Terraform-VMWare-Modules/vm/vsphere"
20-
version = "1.0.0"
21-
vmtemp = "TemplateName"
22-
is_windows_image = "true"
23-
windomain = "Development.com"
24-
domain_admin_user = "Domain admin user"
19+
source = "Terraform-VMWare-Modules/vm/vsphere"
20+
version = "1.0.2"
21+
vmtemp = "TemplateName"
22+
is_windows_image = "true"
23+
windomain = "Development.com"
24+
domain_admin_user = "Domain admin user"
2525
domain_admin_password = "SomePassword"
26-
instances = 1
27-
vmname = "example-server-windows"
28-
vmrp = "esxi/Resources"
29-
network_cards = ["Name of the POrt Group in vSphere"]
26+
instances = 1
27+
vmname = "example-server-windows"
28+
vmrp = "esxi/Resources"
29+
network_cards = ["Name of the Port Group in vSphere"]
3030
ipv4 = {
31-
"Name of the POrt Group in vSphere" = ["10.0.0.1"] # To use DHCP create Empty list for each instance
31+
"Name of the Port Group in vSphere" = ["10.0.0.1"] # To use DHCP create empty string for each instance
3232
}
3333
dc = "Datacenter"
3434
datastore = "Data Store name(use ds_cluster for datastore cluster)"
3535
}
3636
//Example of Windows VM customization with advanced features
3737
module "example-server-windowsvm-advanced" {
3838
source = "Terraform-VMWare-Modules/vm/vsphere"
39-
version = "1.0.0"
39+
version = "1.0.2"
4040
dc = "Datacenter"
4141
vmrp = "cluster/Resources"
4242
vmfolder = "Cattle"
@@ -50,13 +50,13 @@ module "example-server-windowsvm-advanced" {
5050
memory_hot_add_enabled = "true"
5151
vmname = "AdvancedVM"
5252
vmdomain = "somedomain.com"
53-
network_cards = ["VM Network", "test-netwrok"]
53+
network_cards = ["VM Network", "test-network"]
5454
ipv4submask = ["24", "8"]
5555
ipv4 = {
5656
"VM Network" = ["192.168.0.4", ""] // Here the first instance will use Static Ip and Second DHCP
5757
"test" = ["", "192.168.0.3"]
5858
}
59-
data_disk_size_gb = [10, 5] // Aditional Disk to be used
59+
data_disk_size_gb = [10, 5] // Aditional Disks to be used
6060
thin_provisioned = ["true", "false"]
6161
vmdns = ["192.168.0.2", "192.168.0.1"]
6262
vmgateway = "192.168.0.1"
@@ -66,10 +66,10 @@ module "example-server-windowsvm-advanced" {
6666
}
6767
enable_disk_uuid = "true"
6868
auto_logon = "true"
69-
run_once = ["command01", "command02"]
69+
run_once = ["command01", "powershell.exe \"New-Item C:\\test.txt\""] // You can also run Powershell commands
7070
orgname = "Terraform-Module"
7171
workgroup = "Module-Test"
7272
is_windows_image = "true"
7373
firmware = "efi"
7474
local_adminpass = "Password123"
75-
}
75+
}

0 commit comments

Comments
 (0)