feat: render inspec.sh runnner script

This commit is contained in:
Aravinth Manivannan 2023-07-20 13:41:46 +05:30
parent 24fcb154eb
commit 4d374c336b
Signed by: realaravinth
GPG key ID: AD9F0F08E855ED88
2 changed files with 29 additions and 1 deletions

18
conf.tf
View file

@ -34,7 +34,7 @@ variable "loadbalance_count" {
variable "libreddit_count" {
default = 4
default = 2
}
@ -208,3 +208,19 @@ resource "local_file" "nginx_loadbalance_conf" {
filename = "./ansible/assets/nginx.cfg"
}
resource "local_file" "auditor_script" {
content = templatefile("./templates/auditor.tftpl",
{
libreddit_vm_ips = local.libreddit_vm_ips,
libreddit_vm_names = local.libreddit_vm_names,
libreddit_vms = local.libreddit_vm_map,
loadbalance_vm_ips = local.loadbalance_vm_ips,
loadbalance_vm_names = local.loadbalance_vm_names,
loadbalance_vms = local.loadbalance_vm_map
})
filename = "./inspec.sh"
}

12
templates/auditor.tftpl Normal file
View file

@ -0,0 +1,12 @@
#!/bin/bash
%{ for vm in loadbalance_vms ~}
cinc-auditor exec ./inspec/linux-baseline -t ssh://atm@${vm.ip} # ${vm.name}
cinc-auditor exec ./inspec/ssh-baseline -t ssh://atm@${vm.ip} # ${vm.name}
cinc-auditor exec ./inspec/nginx-baseline -t ssh://atm@${vm.ip} # ${vm.name}
%{ endfor ~}
%{ for vm in libreddit_vms ~}
cinc-auditor exec ./inspec/linux-baseline -t ssh://atm@${vm.ip} # ${vm.name}
cinc-auditor exec ./inspec/ssh-baseline -t ssh://atm@${vm.ip} # ${vm.name}
%{ endfor ~}