-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
118 lines (111 loc) · 4.11 KB
/
main.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
provider "openstack" {
version = "~> 1.43.0"
}
resource "openstack_networking_network_v2" "keepalived_openstack_network" {
name = "keepalived_openstack_network"
admin_state_up = "true"
}
resource "openstack_networking_subnet_v2" "keepalived_openstack_subnet" {
network_id = "${openstack_networking_network_v2.keepalived_openstack_network.id}"
cidr = "192.168.60.0/24"
enable_dhcp = "false"
no_gateway = "true"
}
resource "openstack_networking_port_v2" "keepalived_node1_port" {
network_id = "${openstack_networking_network_v2.keepalived_openstack_network.id}"
admin_state_up = "true"
port_security_enabled = "false"
fixed_ip {
subnet_id = "${openstack_networking_subnet_v2.keepalived_openstack_subnet.id}"
ip_address = "192.168.60.11"
}
}
resource "openstack_networking_port_v2" "keepalived_node2_port" {
network_id = "${openstack_networking_network_v2.keepalived_openstack_network.id}"
admin_state_up = "true"
port_security_enabled = "false"
fixed_ip {
subnet_id = "${openstack_networking_subnet_v2.keepalived_openstack_subnet.id}"
ip_address = "192.168.60.12"
}
}
resource "openstack_compute_instance_v2" "chef_zero" {
name = "chef-zero"
image_name = "${var.centos_atomic_image}"
flavor_name = "m1.small"
key_pair = "${var.ssh_key_name}"
security_groups = ["default"]
connection {
user = "centos"
}
network {
uuid = "${data.openstack_networking_network_v2.network.id}"
}
provisioner "remote-exec" {
inline = [
"until [ -S /var/run/docker.sock ] ; do sleep 1 && echo 'docker not started...' ; done",
"sudo docker run -d -p 8889:8889 --name chef-zero osuosl/chef-zero"
]
}
provisioner "local-exec" {
command = "rake knife_upload"
environment = {
CHEF_SERVER = "${openstack_compute_instance_v2.chef_zero.network.0.fixed_ip_v4}"
}
}
}
resource "openstack_compute_instance_v2" "node1" {
name = "node1"
image_name = "${var.centos_image}"
flavor_name = "m1.medium"
key_pair = "${var.ssh_key_name}"
security_groups = ["default"]
connection {
user = "centos"
}
network {
uuid = "${data.openstack_networking_network_v2.network.id}"
}
network {
port = "${openstack_networking_port_v2.keepalived_node1_port.id}"
}
provisioner "chef" {
client_options = ["chef_license 'accept'"]
run_list = ["recipe[keepalived_test::provisioning]"]
node_name = "node1"
secret_key = "${file("test/integration/encrypted_data_bag_secret")}"
server_url = "http://${openstack_compute_instance_v2.chef_zero.network.0.fixed_ip_v4}:8889"
recreate_client = true
user_name = "fakeclient"
user_key = "${file("test/chef-config/fakeclient.pem")}"
version = "${var.chef_version}"
}
}
resource "openstack_compute_instance_v2" "node2" {
name = "node2"
image_name = "${var.centos_image}"
flavor_name = "m1.medium"
key_pair = "${var.ssh_key_name}"
security_groups = ["default"]
depends_on = ["openstack_compute_instance_v2.node1"]
connection {
user = "centos"
}
network {
uuid = "${data.openstack_networking_network_v2.network.id}"
}
network {
port = "${openstack_networking_port_v2.keepalived_node2_port.id}"
}
provisioner "chef" {
client_options = ["chef_license 'accept'"]
run_list = ["recipe[keepalived_test::provisioning]"]
node_name = "node2"
secret_key = "${file("test/integration/encrypted_data_bag_secret")}"
server_url = "http://${openstack_compute_instance_v2.chef_zero.network.0.fixed_ip_v4}:8889"
recreate_client = true
user_name = "fakeclient"
user_key = "${file("test/chef-config/fakeclient.pem")}"
version = "${var.chef_version}"
}
}