This commit is contained in:
Patrick Cao Huu Thien 2023-10-11 19:02:57 +02:00
commit 667ada2402
Signed by untrusted user who does not match committer: pcao
GPG Key ID: B57DBE40C72FBCF4
5 changed files with 71 additions and 0 deletions

16
README.rst Normal file
View File

@ -0,0 +1,16 @@
Terraform module to replace syslogd with rsyslog
Usage
-----
In the root terraform add::
module "rsyslog" {
source = "git::https://git.dalembert.upmc.fr/terraform/module_alpine_rsyslog"
connection_ip = var.eth0_ip
connection_private_key = file(var.pm_private_key)
}
.. vim: spelllang=en:

36
main.tf Normal file
View File

@ -0,0 +1,36 @@
resource "null_resource" "rsyslog" {
connection {
type = "ssh"
user = "root"
host = var.connection_ip
private_key = var.connection_private_key
}
provisioner "file" {
source = "${path.module}/rsyslog.conf"
destination = "/tmp/rsyslog.conf"
}
# execute postinstall script
provisioner "remote-exec" {
inline = [
"echo '# install rsyslog'",
"apk add --no-cache rsyslog",
#
"echo '# disable service syslog'",
"rc-service syslog stop",
"rc-update del syslog",
"rc-update del syslog boot",
#
"echo '# configuration service rsyslog'",
"rc-service rsyslog stop",
"mv /tmp/rsyslog.conf /etc/rsyslog.conf",
"rc-service rsyslog start",
"rc-update add rsyslog boot",
#
"echo;echo '# VM must be restarted to clean syslogd'",
]
}
}

1
rsyslogd-checkconf Executable file
View File

@ -0,0 +1 @@
rsyslogd -f /etc/rsyslog.conf -N1

7
rsyslogd-reload Executable file
View File

@ -0,0 +1,7 @@
if rsyslogd-checkconf
then
echo "Config OK"
rc-service rsyslog restart
else
echo "Abort restarting"
fi

11
variables.tf Normal file
View File

@ -0,0 +1,11 @@
variable "connection_ip" {
type = string
description = "ipv4"
}
variable "connection_private_key" {
type = string
description = "private key for terraform connection"
sensitive = true
}