1
- Type: ` vsphere-virtual_machine `
2
- Artifact BuilderId: ` vsphere.virtual_machine `
1
+ Type: ` vsphere-virtualmachine `
2
+ Artifact BuilderId: ` vsphere.virtualmachine `
3
3
4
- This datasource is able to get information about existing virtual machines from vSphere
4
+ This data source retrieves information about existing virtual machines from vSphere
5
5
and return name of one virtual machine that matches all specified filters. This virtual
6
- machine can later be used in the vSphere Clone builder to select template.
6
+ machine can be used in the vSphere Clone builder to select a template.
7
7
8
8
## Configuration Reference
9
9
10
10
### Filters Configuration
11
11
12
12
** Optional:**
13
13
14
- <!-- Code generated from the comments of the Config struct in datasource/virtual_machine /data.go; DO NOT EDIT MANUALLY -->
14
+ <!-- Code generated from the comments of the Config struct in datasource/virtualmachine /data.go; DO NOT EDIT MANUALLY -->
15
15
16
16
- ` name ` (string) - Basic filter with glob support (e.g. ` nginx_basic* ` ). Defaults to ` * ` .
17
17
Using strict globs will not reduce execution time because vSphere API returns the full inventory.
18
18
But can be used for better readability over regular expressions.
19
19
20
20
- ` name_regex ` (string) - Extended name filter with regular expressions support (e.g. ` nginx[-_]basic[0-9]* ` ). Default is empty.
21
21
The match of the regular expression is checked by substring. Use ` ^ ` and ` $ ` to define a full string.
22
- E.g. the ` ^[^_]+$ ` filter will search names without any underscores.
22
+ For example, the ` ^[^_]+$ ` filter will search names without any underscores.
23
23
The expression must use [ Go Regex Syntax] ( https://pkg.go.dev/regexp/syntax ) .
24
24
25
25
- ` template ` (bool) - Filter to return only objects that are virtual machine templates.
26
- Defaults to ` false ` and returns all VMs .
26
+ Defaults to ` false ` and returns all virtual machines .
27
27
28
- - ` node ` (string) - Filter to search virtual machines only on the specified node .
28
+ - ` host ` (string) - Filter to search virtual machines only on the specified ESX host .
29
29
30
- - ` vm_tags ` ([ ] Tag) - Filter to return only that virtual machines that have attached all specifies tags.
31
- Specify one or more ` vm_tags ` blocks to define list of tags that will make up the filter.
32
- Should work since vCenter 6.7. To avoid incompatibility, REST client is being
33
- initialized only when at least one tag has been defined in the config.
30
+ - ` tags ` ([ ] Tag) - Filter to return only that virtual machines that have attached all specifies tags.
31
+ Specify one or more ` tags ` blocks to define list of tags for the filter.
34
32
35
33
- ` latest ` (bool) - This filter determines how to handle multiple machines that were matched with all
36
34
previous filters. Machine creation time is being used to find latest.
37
35
By default, multiple matching machines results in an error.
38
36
39
- <!-- End of code generated from the comments of the Config struct in datasource/virtual_machine /data.go; -->
37
+ <!-- End of code generated from the comments of the Config struct in datasource/virtualmachine /data.go; -->
40
38
41
39
42
40
### Tags Filter Configuration
43
41
44
- <!-- Code generated from the comments of the Tag struct in datasource/virtual_machine /data.go; DO NOT EDIT MANUALLY -->
42
+ <!-- Code generated from the comments of the Tag struct in datasource/virtualmachine /data.go; DO NOT EDIT MANUALLY -->
45
43
46
- Example of multiple vm_tags blocks in HCL format:
47
- ```
44
+ HCL Example:
45
+
46
+ ``` hcl
48
47
49
- vm_tags {
48
+ tags {
50
49
category = "team"
51
50
name = "operations"
52
51
}
53
- vm_tags {
54
- category = "SLA "
52
+ tags {
53
+ category = "sla "
55
54
name = "gold"
56
55
}
57
56
58
57
```
59
58
60
- <!-- End of code generated from the comments of the Tag struct in datasource/virtual_machine /data.go; -->
59
+ <!-- End of code generated from the comments of the Tag struct in datasource/virtualmachine /data.go; -->
61
60
62
61
63
62
** Required:**
64
63
65
- <!-- Code generated from the comments of the Tag struct in datasource/virtual_machine /data.go; DO NOT EDIT MANUALLY -->
64
+ <!-- Code generated from the comments of the Tag struct in datasource/virtualmachine /data.go; DO NOT EDIT MANUALLY -->
66
65
67
66
- ` name ` (string) - Tag with this name must be attached to virtual machine which should pass the Tags Filter.
68
67
69
68
- ` category ` (string) - Name of the category that contains this tag. Both tag and category must be specified.
70
69
71
- <!-- End of code generated from the comments of the Tag struct in datasource/virtual_machine /data.go; -->
70
+ <!-- End of code generated from the comments of the Tag struct in datasource/virtualmachine /data.go; -->
72
71
73
72
74
73
### Connection Configuration
@@ -100,48 +99,47 @@ Example of multiple vm_tags blocks in HCL format:
100
99
101
100
## Output
102
101
103
- <!-- Code generated from the comments of the DatasourceOutput struct in datasource/virtual_machine /data.go; DO NOT EDIT MANUALLY -->
102
+ <!-- Code generated from the comments of the DatasourceOutput struct in datasource/virtualmachine /data.go; DO NOT EDIT MANUALLY -->
104
103
105
104
- ` vm_name ` (string) - Name of the found virtual machine.
106
105
107
- <!-- End of code generated from the comments of the DatasourceOutput struct in datasource/virtual_machine /data.go; -->
106
+ <!-- End of code generated from the comments of the DatasourceOutput struct in datasource/virtualmachine /data.go; -->
108
107
109
108
110
109
## Example Usage
111
110
112
- This is a very basic example that connects to vSphere cluster and tries to search
113
- the latest virtual machine that matches all filters. The machine name is then printed
114
- to console as output variable.
111
+ This example demonstrates how to connect to vSphere cluster and search for the latest virtual machine
112
+ that matches the filters. The name of the machine is then output to the console as an output variable.
115
113
``` hcl
116
- data "vsphere-virtual_machine " "default" {
117
- vcenter_server = "vcenter.example.org "
114
+ data "vsphere-virtualmachine " "default" {
115
+ vcenter_server = "vcenter.example.com "
118
116
insecure_connection = true
119
- username = "administrator@example.org "
120
- password = "St4ongPa$$w0rd "
121
- datacenter = "AZ1 "
117
+ username = "administrator@vsphere.local "
118
+ password = "VMware1! "
119
+ datacenter = "dc-01 "
122
120
latest = true
123
- vm_tags {
121
+ tags {
124
122
category = "team"
125
123
name = "operations"
126
124
}
127
- vm_tags {
128
- category = "SLA "
125
+ tags {
126
+ category = "sla "
129
127
name = "gold"
130
128
}
131
129
132
130
}
133
131
134
132
locals {
135
- vm_name = data.vsphere-virtual_machine .default.vm_name
133
+ vm_name = data.vsphere-virtualmachine .default.vm_name
136
134
}
137
135
138
- source "null" "basic- example" {
136
+ source "null" "example" {
139
137
communicator = "none"
140
138
}
141
139
142
140
build {
143
141
sources = [
144
- "source.null.basic- example"
142
+ "source.null.example"
145
143
]
146
144
147
145
provisioner "shell-local" {
@@ -150,6 +148,4 @@ build {
150
148
]
151
149
}
152
150
}
153
-
154
-
155
151
```
0 commit comments