Add monitoring auto-deployment

This commit is contained in:
Your Name
2026-09-19 13:13:47 +05:00
commit 86e1c44d85
16 changed files with 422 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
locals {
ssh_user = "ubuntu"
ssh_private_key = "~/.ssh/ssh-key-1789658954721"
}
resource "local_file" "ansible_host_vars" {
count = length(yandex_compute_instance.server)
filename = "${path.module}/../host_vars/${yandex_compute_instance.server[count.index].name}.yml"
directory_permission = "0755"
file_permission = "0644"
content = <<-EOT
ansible_host: "${yandex_compute_instance.server[count.index].network_interface.0.nat_ip_address}"
ansible_user: "${local.ssh_user}"
ansible_ssh_private_key_file: "${local.ssh_private_key}"
EOT
}
resource "local_file" "ansible_inventory" {
filename = "${path.module}/inventory.ini"
directory_permission = "0755"
file_permission = "0644"
content = templatefile("${path.module}/inventory.ini.tftpl", {
hosts = yandex_compute_instance.server[*].name
})
depends_on = [local_file.ansible_host_vars]
}