-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweb.tf
59 lines (50 loc) · 1.37 KB
/
web.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
provider "openstack" {
user_name = "testuser"
tenant_name = "testProject"
password = "testuser"
auth_url = "http://192.168.122.250:5000"
region = "RegionOne"
}
# set instance
resource "openstack_compute_instance_v2" "web1" {
name = "web1"
image_name = "centos7"
flavor_name = "myflavor"
key_pair = "testkey"
security_groups = ["ssh/http/icmp"]
network {
name = "int-net"
}
depends_on = [
openstack_networking_floatingip_v2.fip1,
]
}
resource "openstack_compute_instance_v2" "web2" {
name = "web2"
image_name = "centos7"
flavor_name = "myflavor"
key_pair = "testkey"
security_groups = ["ssh/http/icmp"]
network {
name = "int-net"
}
depends_on = [
openstack_networking_floatingip_v2.fip2,
]
}
# set fip
resource "openstack_networking_floatingip_v2" "fip1" {
pool = "public" # static setted
}
resource "openstack_networking_floatingip_v2" "fip2" {
pool = "public" # static setted
}
# associate fip
resource "openstack_compute_floatingip_associate_v2" "webip1" {
floating_ip = openstack_networking_floatingip_v2.fip1.address
instance_id = openstack_compute_instance_v2.web1.id
}
resource "openstack_compute_floatingip_associate_v2" "webip2" {
floating_ip = openstack_networking_floatingip_v2.fip2.address
instance_id = openstack_compute_instance_v2.web2.id
}