-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tf
More file actions
51 lines (42 loc) · 1.48 KB
/
main.tf
File metadata and controls
51 lines (42 loc) · 1.48 KB
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
provider "docker" {
host = "unix:///var/run/docker.sock" //alter to your docker location
}
locals {
nginx_client_count = 4 //set number of nginx containers to deploy
ubuntu_client_count = 4 //set number of ubuntu containers to deploy
grr_pass = random_password.password.result //set a password here to log into the GRR admin interface
network_subnet = "172.20.0.0/16" //set network subnet here
}
resource "random_password" "password" {
length = 16
special = true
override_special = "_%@"
}
module "grr-docker-lab" {
source = "./modules/grr-docker-lab/"
nginx_client_count = local.nginx_client_count
ubuntu_client_count = local.ubuntu_client_count
grr_pass = local.grr_pass
network_subnet = local.network_subnet
network_gateway = cidrhost(local.network_subnet, 1)
}
resource "null_resource" "build-grr-client"{
depends_on = [module.grr-docker-lab]
provisioner "local-exec" {
command = "docker exec grr-admin /buildclient.sh"
}
provisioner "local-exec" {
when = destroy
command = "./scripts/rmimages.sh"
}
}
resource "null_resource" "deploy-grr"{
count = (local.nginx_client_count + local.ubuntu_client_count)
depends_on = [null_resource.build-grr-client]
provisioner "local-exec" {
command = "docker exec -u grr-user ${module.grr-docker-lab.client_names[count.index]} /grr-deploy-data/clientdeploy.sh"
}
}
output "grr_pass" {
value = local.grr_pass
}