Skip to content

Commit

Permalink
feat(instances): add command to attach server in portainer
Browse files Browse the repository at this point in the history
  • Loading branch information
igr-santos committed Nov 12, 2024
1 parent bccfc1d commit 4334664
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions instances/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ module "legacy_server" {
monitoring_files_path = "./monitoring"
influxdb_token = var.influxdb_token
elastic_ip_allocation_id = var.legacy_elastic_ip_allocation_id
portainer_edge_id = var.legacy_portainer_edge_id
portainer_edge_key = var.legacy_portainer_edge_key
}

# module "sites_server" {
Expand Down
2 changes: 2 additions & 0 deletions instances/modules/common/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ resource "aws_instance" "server" {
"sudo su -c 'echo \"INFLUXDB_TOKEN=${var.influxdb_token}\" >> /etc/default/telegraf'",
# Reinicia o telegraf para garantir que a variavel está configurada
"sudo systemctl restart telegraf",
# Adiciona essa instância ao Portainer
"sudo docker run -d -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker/volumes:/var/lib/docker/volumes -v /:/host -v portainer_agent_data:/data --restart always -e EDGE=1 -e EDGE_ID=${var.portainer_edge_id} -e EDGE_KEY=${var.portainer_edge_key} -e EDGE_INSECURE_POLL=1 --name portainer_edge_agent portainer/agent:2.15.1"
]

connection {
Expand Down
11 changes: 11 additions & 0 deletions instances/modules/common/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,15 @@ variable "elastic_ip_allocation_id" {
description = "ID da alocação de um IP Elástico da AWS"
type = string
default = ""
}

variable "portainer_edge_id" {
description = "ID do ambiente no Portainer"
type = string
}

variable "portainer_edge_key" {
description = "Chave Secreta do ambiente no Portainer"
type = string
sensitive = true
}
11 changes: 11 additions & 0 deletions instances/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,15 @@ variable "sites_server_instance_type" {
description = "Tipo de instância para o servidor de sites (Bonde Público e CMS)"
type = string
default = "t3.micro"
}

variable "legacy_portainer_edge_id" {
description = "ID do ambiente no Portainer"
type = string
}

variable "legacy_portainer_edge_key" {
description = "Chave Secreta do ambiente no Portainer"
type = string
sensitive = true
}

0 comments on commit 4334664

Please sign in to comment.