-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.tf
109 lines (93 loc) · 2.76 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
/*
./terraformDocker.sh destroy -auto-approve && ./terraformDocker.sh apply -var-file="secrets.tfvars" -auto-approve
./terraformDocker.sh apply -var-file="secrets.tfvars" -auto-approve
./terraformDocker.sh destroy -auto-approve
# CRC and SNC
sudo journalctl -u google-startup-scripts.service -f
# CRC
sudo journalctl -u crc.service -f
sudo tail -f /var/log/messages -n +1 | grep runuser
sudo cat /var/log/messages | grep runuser
# SNC
tail -f /home/crcuser/snc/install.out
*/
data "template_file" "default" {
template = file("${path.module}/init.tpl")
vars = {
file_inadyn_conf = data.template_file.inadyn_conf.rendered
file_provision_yml = base64encode(data.template_file.provision_yml.rendered)
file_ddns_j2 = file("${path.module}/ddns.j2")
file_crc_j2 = file("${path.module}/crc.j2")
file_banner = file("${path.module}/banner.txt")
file_tools_sh = file("${path.module}/tools.sh")
strategy = var.strategy
}
}
data "template_file" "inadyn_conf" {
template = file("${path.module}/inadyn.conf")
vars = {
ddns_provider = var.ddns_provider
ddns_login = var.ddns_login
ddns_password = var.ddns_password
ddns_hostname = var.ddns_hostname
}
}
data "template_file" "provision_yml" {
template = file("${path.module}/provision.yml")
vars = {
ddns_enabled = var.ddns_enabled
docker_login = var.docker_login
docker_password = var.docker_password
strategy: var.strategy
crc_pull_secret = file("${path.module}/pull-secret.txt")
crc_snc_memory = var.crc_snc_memory
crc_snc_cpus = var.crc_snc_cpus
snc_disk_size = var.snc_disk_size
crc_monitoring_enabled = var.crc_monitoring_enabled
}
}
resource "google_compute_instance" "crc-build-box" {
name = "${var.instance-name}-1"
machine_type = var.gcp_vm_type
zone = var.zone
#min_cpu_platform = "Intel Haswell"
tags = [
"default-firewall-ssh",
"default-firewall-http",
"default-firewall-https",
"default-firewall-icmp",
"default-firewall-openshift-console",
"default-firewall-secure-forward",
]
scheduling {
automatic_restart = false
preemptible = var.gcp_vm_preemptible
}
advanced_machine_features {
enable_nested_virtualization = true
}
boot_disk {
initialize_params {
image = var.image
type = var.gcp_vm_disk_type
size = local.gcp_vm_disk_size
}
}
metadata = {
ssh-keys = "crcuser:${file("crcuser_key.pub")}"
}
metadata_startup_script = data.template_file.default.rendered
network_interface {
#subnetwork = "${google_compute_subnetwork.crc_network_subnetwork.name}"
network = "default"
access_config {
// Ephemeral IP
}
}
timeouts {
create = "60m"
}
}
resource "google_compute_project_default_network_tier" "default" {
network_tier = "STANDARD"
}