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:
48
45
46
+ ``` hcl
49
47
vm_tags {
50
48
category = "team"
51
49
name = "operations"
52
50
}
53
51
vm_tags {
54
- category = "SLA "
52
+ category = "sla "
55
53
name = "gold"
56
54
}
57
-
58
55
```
59
56
60
- <!-- End of code generated from the comments of the Tag struct in datasource/virtual_machine /data.go; -->
57
+ <!-- End of code generated from the comments of the Tag struct in datasource/virtualmachine /data.go; -->
61
58
62
59
63
60
** Required:**
64
61
65
- <!-- Code generated from the comments of the Tag struct in datasource/virtual_machine /data.go; DO NOT EDIT MANUALLY -->
62
+ <!-- Code generated from the comments of the Tag struct in datasource/virtualmachine /data.go; DO NOT EDIT MANUALLY -->
66
63
67
64
- ` name ` (string) - Tag with this name must be attached to virtual machine which should pass the Tags Filter.
68
65
69
66
- ` category ` (string) - Name of the category that contains this tag. Both tag and category must be specified.
70
67
71
- <!-- End of code generated from the comments of the Tag struct in datasource/virtual_machine /data.go; -->
68
+ <!-- End of code generated from the comments of the Tag struct in datasource/virtualmachine /data.go; -->
72
69
73
70
74
71
### Connection Configuration
@@ -100,48 +97,47 @@ Example of multiple vm_tags blocks in HCL format:
100
97
101
98
## Output
102
99
103
- <!-- Code generated from the comments of the DatasourceOutput struct in datasource/virtual_machine /data.go; DO NOT EDIT MANUALLY -->
100
+ <!-- Code generated from the comments of the DatasourceOutput struct in datasource/virtualmachine /data.go; DO NOT EDIT MANUALLY -->
104
101
105
102
- ` vm_name ` (string) - Name of the found virtual machine.
106
103
107
- <!-- End of code generated from the comments of the DatasourceOutput struct in datasource/virtual_machine /data.go; -->
104
+ <!-- End of code generated from the comments of the DatasourceOutput struct in datasource/virtualmachine /data.go; -->
108
105
109
106
110
107
## Example Usage
111
108
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.
109
+ This example demonstrates how to connect to vSphere cluster and search for the latest virtual machine
110
+ that matches the filters. The name of the machine is then output to the console as an output variable.
115
111
``` hcl
116
- data "vsphere-virtual_machine " "default" {
117
- vcenter_server = "vcenter.example.org "
112
+ data "vsphere-virtualmachine " "default" {
113
+ vcenter_server = "vcenter.example.com "
118
114
insecure_connection = true
119
- username = "administrator@example.org "
120
- password = "St4ongPa$$w0rd "
121
- datacenter = "AZ1 "
115
+ username = "administrator@vsphere.local "
116
+ password = "VMware1! "
117
+ datacenter = "dc-01 "
122
118
latest = true
123
119
vm_tags {
124
120
category = "team"
125
121
name = "operations"
126
122
}
127
123
vm_tags {
128
- category = "SLA "
124
+ category = "sla "
129
125
name = "gold"
130
126
}
131
127
132
128
}
133
129
134
130
locals {
135
- vm_name = data.vsphere-virtual_machine .default.vm_name
131
+ vm_name = data.vsphere-virtualmachine .default.vm_name
136
132
}
137
133
138
- source "null" "basic- example" {
134
+ source "null" "example" {
139
135
communicator = "none"
140
136
}
141
137
142
138
build {
143
139
sources = [
144
- "source.null.basic- example"
140
+ "source.null.example"
145
141
]
146
142
147
143
provisioner "shell-local" {
@@ -150,6 +146,4 @@ build {
150
146
]
151
147
}
152
148
}
153
-
154
-
155
149
```
0 commit comments