-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathrunjobs.tf
136 lines (118 loc) · 3.34 KB
/
runjobs.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# Configure the Nomad provider
provider "nomad" {
address = data.terraform_remote_state.demostack.outputs.Primary_Nomad
}
locals {
fabio = "${data.terraform_remote_state.demostack.outputs.Primary_Fabio}"
workers = "${data.terraform_remote_state.demostack.outputs.Primary_nomad_tag_workers}"
servers = "${data.terraform_remote_state.demostack.outputs.Primary_nomad_tag_servers}"
}
// Workspace Data
data "terraform_remote_state" "demostack" {
backend = "remote"
config = {
hostname = "app.terraform.io"
organization = var.TFE_ORGANIZATION
workspaces = {
name = var.DEMOSTACK_WORKSPACE
}
} //config
}
/*
# Register a job
resource "nomad_job" "nginx-pki" {
jobspec = "${file("./nginx-pki.nomad")}"
}
resource "nomad_job" "hashibo" {
jobspec = "${file("./hashibo.nomad")}"
}
*/
/*
resource "nomad_job" "consul-federation" {
jobspec = "${file("./consul-federation.nomad")}"
}
*/
# resource "nomad_job" "nomad-federation" {
# jobspec = "${file("./nomad_federation.nomad")}"
# }
/*
resource "nomad_job" "countapi" {
jobspec = "${file("./countapi.nomad")}"
}
resource "nomad_job" "countdashboard" {
jobspec = "${file("./countdashboard.nomad")}"
}
*/
resource "nomad_job" "postgresSQL" {
jobspec = "${file("./postgresSQL.nomad")}"
}
resource "nomad_job" "postgresSQL_admin" {
jobspec = "${file("./pgadmin.nomad")}"
}
resource "nomad_job" "ldap-server" {
jobspec = "${file("./ldap-server.nomad")}"
}
resource "nomad_job" "phpldapadmin" {
jobspec = "${file("./phpldapadmin.nomad")}"
}
resource "nomad_job" "vaultupdater" {
jobspec = "${file("./vaultupdater.nomad")}"
}
/*
data "template_file" "vault-ssh-helper" {
count = length(local.workers)
template = "${file("./vault-ssh-helper.nomad.tpl")}"
vars = {
nomad_node = local.workers[count.index]
}
}
resource "nomad_job" "vault-ssh-helper" {
count = length(local.workers)
jobspec = "${element(data.template_file.vault-ssh-helper.*.rendered, count.index)}"
}
*/
# data "template_file" "vault-ssh-helper# template = ${file# vars = {
# nomad_node = "ric-lnd-stack-server-1"
# }
# }
# resource "nomad_job" "vault-ssh-ca" {
# jobspec = "${data.template_file.vault-ssh-ca.rendered}"
# }
### Monitoring Stack (may need to be applied twice)
data "template_file" "prometheus_monitoring" {
template = "${file("./prometheus.nomad.tpl")}"
vars = {
fabio_url = "${local.fabio}"
fabio_srv = substr(local.fabio, 7, length(local.fabio))
}
}
resource "nomad_job" "prometheus_monitoring" {
jobspec = "${data.template_file.prometheus_monitoring.rendered}"
}
provider "grafana" {
url = "${local.fabio}/grafana"
auth = "admin:admin"
}
resource "grafana_data_source" "prometheus" {
type = "prometheus"
name = "prometheus"
url = "http://prometheus.service.consul:9090"
is_default = "true"
}
resource "grafana_dashboard" "Nomad" {
config_json = "${file("./grafana/Nomad.json")}"
}
resource "grafana_dashboard" "Consul" {
config_json = "${file("./grafana/Consul.json")}"
}
resource "grafana_dashboard" "Vault" {
config_json = "${file("./grafana/Vault.json")}"
}
# resource "grafana_data_source" "influxdb" {
# type = "influxdb"
# name = "test_influxdb"
# url = "http://influxdb.example.net:8086/"
# username = "foo"
# password = "bar"
# database_name = "mydb"
# }