- dns for agent

- del count instances
- fix script for agent
- fix vps.tf
This commit is contained in:
Vassiliy Yegorov
2019-07-13 12:10:24 +07:00
parent 0ef4cade94
commit f9dd4f2f4b
7 changed files with 431 additions and 16 deletions

View File

@@ -1,12 +1,11 @@
#===============================================
# Create PVE servers
#===============================================
resource "google_compute_instance" "pve" {
count = "${var.count_instance}"
name = "serv-${count.index + 1}"
resource "google_compute_instance" "agent" {
name = "agent-1"
machine_type = "g1-small"
zone = "${var.zone_instance}"
tags = ["serv-${count.index + 1}"]
tags = ["${var.zabbix_tag}"]
# add image disk
boot_disk {
@@ -26,8 +25,6 @@ resource "google_compute_instance" "pve" {
sshKeys = "${var.default_user}:${file("~/.ssh/id_rsa.pub")}"
}
metadata_startup_script = "${file("scripts/setupagent.sh")}"
connection {
host = self.network_interface.0.access_config.0.nat_ip
type = "ssh"
@@ -35,18 +32,23 @@ resource "google_compute_instance" "pve" {
private_key = "${file("~/.ssh/id_rsa")}"
}
provisioner "remote-exec" {
inline = ["${file("scripts/setupagent.sh")}"]
}
provisioner "file" {
source = "scripts/agents/zabbix_agent.conf"
destination = "/etc/zabbix/zabbix_agent.conf"
source = "scripts/agents/zabbix_agentd.conf"
destination = "~/zabbix_agentd.conf"
}
provisioner "remote-exec" {
inline = [
"sudo apt update",
"sudo apt install nginx -y",
"sudo echo Serv-${count.index + 1} >> /var/www/html/index.nginx-debian.html",
"sudo systemctl enable nginx && sudo systemctl start nginx"
"sudo echo ${self.name} >> /var/www/html/index.nginx-debian.html",
"sudo systemctl enable nginx && sudo systemctl start nginx",
"sudo cp ~/zabbix_agentd.conf /etc/zabbix/",
"sudo service zabbix-agent restart"
]
}
}