1
1
# create a public IP address for the virtual machine
2
2
resource "azurerm_public_ip" "automate_pubip" {
3
- name = " automate_pubip"
4
- location = " ${ var . azure_region } "
5
- resource_group_name = " ${ azurerm_resource_group . rg . name } "
6
- public_ip_address_allocation = " dynamic"
7
- domain_name_label = " ${ var . automate_server_name } -${ lower (substr (" ${ join (" " , split (" :" , timestamp ()))} " , 8 , - 1 ))} "
8
-
9
- tags {
10
- environment = " ${ var . azure_env } "
11
- }
3
+ name = " automate_pubip"
4
+ location = var. azure_region
5
+ resource_group_name = azurerm_resource_group. rg . name
6
+ allocation_method = " Dynamic"
7
+ domain_name_label = " ${ var . automate_server_name } -${ lower (substr (join (" " , split (" :" , timestamp ())), 8 , - 1 ))} "
12
8
}
13
9
14
10
# create the network interface and put it on the proper vlan/subnet
15
11
resource "azurerm_network_interface" "automate_ip" {
16
12
name = " automate_ip"
17
- location = " ${ var . azure_region } "
18
- resource_group_name = " ${ azurerm_resource_group . rg . name } "
13
+ location = var. azure_region
14
+ resource_group_name = azurerm_resource_group. rg . name
19
15
20
16
ip_configuration {
21
17
name = " automate_ipconf"
22
- subnet_id = " ${ azurerm_subnet . subnet . id } "
18
+ subnet_id = azurerm_subnet. subnet . id
23
19
private_ip_address_allocation = " static"
24
20
private_ip_address = " 10.1.1.11"
25
- public_ip_address_id = " ${ azurerm_public_ip . automate_pubip . id } "
21
+ public_ip_address_id = azurerm_public_ip. automate_pubip . id
26
22
}
27
23
}
28
24
29
25
# create the actual VM
30
26
resource "azurerm_virtual_machine" "automate" {
31
27
name = " automate"
32
- location = " ${ var . azure_region } "
33
- resource_group_name = " ${ azurerm_resource_group . rg . name } "
34
- network_interface_ids = [" ${ azurerm_network_interface . automate_ip . id } " ]
35
- vm_size = " ${ var . automate_vm_size } "
28
+ location = var. azure_region
29
+ resource_group_name = azurerm_resource_group. rg . name
30
+ network_interface_ids = [azurerm_network_interface . automate_ip . id ]
31
+ vm_size = var. automate_vm_size
36
32
37
33
storage_image_reference {
38
34
publisher = " Canonical"
@@ -49,24 +45,20 @@ resource "azurerm_virtual_machine" "automate" {
49
45
}
50
46
51
47
os_profile {
52
- computer_name = " ${ var . automate_server_name } "
53
- admin_username = " ${ var . username } "
54
- admin_password = " ${ var . password } "
48
+ computer_name = var. automate_server_name
49
+ admin_username = var. username
50
+ admin_password = var. password
55
51
}
56
52
57
53
os_profile_linux_config {
58
54
disable_password_authentication = false
59
55
}
60
56
61
- tags {
62
- environment = " ${ var . azure_env } "
63
- }
64
-
65
57
connection {
66
- host = " ${ azurerm_public_ip . automate_pubip . fqdn } "
58
+ host = azurerm_public_ip. automate_pubip . fqdn
67
59
type = " ssh"
68
- user = " ${ var . username } "
69
- password = " ${ var . password } "
60
+ user = var. username
61
+ password = var. password
70
62
}
71
63
72
64
provisioner "file" {
@@ -94,25 +86,21 @@ resource "azurerm_virtual_machine" "automate" {
94
86
destination = " /tmp/admin-linux-baseline-2.2.2.tar.gz"
95
87
}
96
88
97
-
98
89
provisioner "file" {
99
90
source = " profiles/admin-linux-patch-baseline-0.4.0.tar.gz"
100
91
destination = " /tmp/admin-linux-patch-baseline-0.4.0.tar.gz"
101
92
}
102
93
103
-
104
94
provisioner "file" {
105
95
source = " profiles/admin-windows-baseline-1.1.0.tar.gz"
106
96
destination = " /tmp/admin-windows-baseline-1.1.0.tar.gz"
107
97
}
108
98
109
-
110
99
provisioner "file" {
111
100
source = " profiles/admin-windows-patch-baseline-0.4.0.tar.gz"
112
101
destination = " /tmp/admin-windows-patch-baseline-0.4.0.tar.gz"
113
102
}
114
103
115
-
116
104
provisioner "remote-exec" {
117
105
inline = [
118
106
" sudo chmod +x /tmp/InstallChefAutomate.sh" ,
@@ -122,5 +110,6 @@ resource "azurerm_virtual_machine" "automate" {
122
110
}
123
111
124
112
output "afqdn" {
125
- value = " ${ azurerm_public_ip . automate_pubip . fqdn } "
113
+ value = azurerm_public_ip. automate_pubip . fqdn
126
114
}
115
+
0 commit comments