2022-11-28 15:00:25 +00:00
|
|
|
#
|
|
|
|
# module "node_exporter" {
|
|
|
|
# source = "git::https://git.dalembert.upmc.fr/terraform/module_alpine_prometheus_node_exporter"
|
|
|
|
# connection_ip = var.eth0_ip
|
|
|
|
# connection_private_key = file(var.pm_private_key)
|
|
|
|
# node_exporter_version = var.node_exporter_version
|
|
|
|
# }
|
|
|
|
|
|
|
|
|
2022-11-28 14:25:14 +00:00
|
|
|
resource "null_resource" "alpine_prometheus_node_exporter" {
|
|
|
|
triggers = {
|
|
|
|
source = filesha256("${path.module}/node_exporter.initd")
|
|
|
|
}
|
|
|
|
connection {
|
|
|
|
type = "ssh"
|
|
|
|
user = "root"
|
|
|
|
host = var.connection_ip
|
|
|
|
private_key = var.connection_private_key
|
|
|
|
}
|
|
|
|
|
|
|
|
provisioner "file" {
|
|
|
|
source = "${path.module}/node_exporter.initd"
|
|
|
|
destination = "/tmp/node_exporter.initd"
|
|
|
|
}
|
|
|
|
|
|
|
|
provisioner "remote-exec" {
|
|
|
|
inline = [
|
|
|
|
"echo '#--------------------------------'",
|
|
|
|
"echo '# module prometheus_node_exporter'",
|
|
|
|
"echo '#--------------------------------'",
|
|
|
|
"wget -nc -q https://github.com/prometheus/node_exporter/releases/download/v${var.node_exporter_version}/node_exporter-${var.node_exporter_version}.linux-amd64.tar.gz",
|
|
|
|
"tar xzf node_exporter-${var.node_exporter_version}.linux-amd64.tar.gz node_exporter-${var.node_exporter_version}.linux-amd64/node_exporter",
|
|
|
|
"echo '# install node_exporter in /usr/sbin'",
|
|
|
|
"install -Dm755 node_exporter-${var.node_exporter_version}.linux-amd64/node_exporter /usr/sbin",
|
|
|
|
#
|
|
|
|
"echo '# install service node_exporter'",
|
|
|
|
"install -Dm755 /tmp/node_exporter.initd /etc/init.d/node_exporter",
|
|
|
|
#
|
|
|
|
"echo '# enable service node_exporter'",
|
|
|
|
"rc-update add node_exporter",
|
2022-11-30 13:58:04 +00:00
|
|
|
"rc-service node_exporter start",
|
2022-11-28 14:25:14 +00:00
|
|
|
#
|
2022-11-30 13:58:04 +00:00
|
|
|
"echo '# clean'",
|
|
|
|
"rm -rf node_exporter-${var.node_exporter_version}.linux-amd64.tar.gz node_exporter-${var.node_exporter_version}.linux-amd64",
|
2022-11-28 14:25:14 +00:00
|
|
|
"echo '# module DONE'",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|