-
Notifications
You must be signed in to change notification settings - Fork 12
/
zenoss.tf
72 lines (59 loc) · 1.57 KB
/
zenoss.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
variable "region_zone" {
default = [ "europe-west3-b", "europe-west2-a" ]
}
variable "the_count" {
default = "1"
}
// alternative testing images debian-9-stretch-v20180611 , ubuntu-1604-xenial-v20180612, ubuntu-1804-bionic-v20180717b
variable "image" {
default = "centos-7-v20180507"
}
resource "google_compute_firewall" "default" {
name = "zenoss-firewall"
network = "default"
allow {
protocol = "tcp"
ports = ["22","80","443","4979"]
}
source_ranges = ["0.0.0.0/0"]
target_tags = ["zenoss"]
}
resource "google_compute_disk" "zenoss-disk" {
count = "${var.the_count}"
name = "zenoss-disk-${count.index}"
size = 40
zone = "${element(var.region_zone, count.index)}"
}
resource "google_compute_instance" "default" {
count = "${var.the_count}"
name = "zenoss${count.index}"
machine_type = "n1-highmem-4"
zone = "${element(var.region_zone, count.index)}"
tags = ["zenoss"]
depends_on = ["google_compute_disk.zenoss-disk"]
boot_disk {
initialize_params {
image = "${var.image}"
}
}
attached_disk {
source = "zenoss-disk-${count.index}"
device_name = "data"
}
network_interface {
network = "default"
access_config {
}
}
metadata_startup_script = <<SCRIPT
echo "startup script"
[[ `lsb_release -cs` == 'bionic' ]] && apt-get -y install python
[[ `lsb_release -is` == 'Ubuntu' ]] && service sshguard stop
SCRIPT
}
output "instance_id" {
value = "${google_compute_instance.default.*.self_link}"
}
output "nat_ip" {
value = "${google_compute_instance.default.*.network_interface.0.access_config.0.nat_ip}"
}