From 4d374c336b74ec889430331ac7edeb73ac5b121e Mon Sep 17 00:00:00 2001 From: Aravinth Manivannan Date: Thu, 20 Jul 2023 13:41:46 +0530 Subject: [PATCH] feat: render inspec.sh runnner script --- conf.tf | 18 +++++++++++++++++- templates/auditor.tftpl | 12 ++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 templates/auditor.tftpl diff --git a/conf.tf b/conf.tf index e04ebe9..abed6d5 100644 --- a/conf.tf +++ b/conf.tf @@ -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" +} diff --git a/templates/auditor.tftpl b/templates/auditor.tftpl new file mode 100644 index 0000000..61f8bd5 --- /dev/null +++ b/templates/auditor.tftpl @@ -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 ~}