From d9aaf2bc953d68e79a14e33fdb21e13f830ab8a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Rodr=C3=ADguez?= Date: Wed, 15 Jan 2025 13:49:22 +0100 Subject: [PATCH 1/4] Add syslog configuration to preprocessing It uses two vars, boolean enduro_use_syslog for enabling, and enduro_remote_syslog: "" for forwarding. --- defaults/main.yml | 4 ++++ handlers/main.yml | 8 ++++++++ tasks/configure-logging.yml | 19 +++++++++++++++++++ tasks/configure-preprocessing-worker.yml | 13 +++++++++++-- templates/logrotate.conf.j2 | 13 +++++++++++++ templates/preprocessing-worker.service.j2 | 6 +++++- templates/rsyslog.conf.j2 | 13 +++++++++++++ 7 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 tasks/configure-logging.yml create mode 100644 templates/logrotate.conf.j2 create mode 100644 templates/rsyslog.conf.j2 diff --git a/defaults/main.yml b/defaults/main.yml index c0d7f0f..c5e2a61 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -59,6 +59,10 @@ enduro_systemd_credentials: false enduro_config_file: "templates/enduro.toml.j2" preprocessing_config_file: "templates/preprocessing-worker.toml.j2" +# Logging configuration +enduro_use_syslog: false +enduro_remote_syslog: "none" + # Enduro pipelines enduro_pipelines: [] diff --git a/handlers/main.yml b/handlers/main.yml index a49bfa3..daf602e 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -19,3 +19,11 @@ daemon_reload: true name: preprocessing-worker state: restarted + +- name: restart rsyslog + become: true + systemd: + daemon_reload: true + name: rsyslog + state: restarted + when: enduro_use_syslog|bool diff --git a/tasks/configure-logging.yml b/tasks/configure-logging.yml new file mode 100644 index 0000000..efb0318 --- /dev/null +++ b/tasks/configure-logging.yml @@ -0,0 +1,19 @@ +- name: "Create logs folder" + become: yes + file: + path: "/var/log/enduro/" + owner: "{{ enduro_system_user }}" + group: "{{ enduro_system_group }}" + mode: 0755 + state: "directory" + +- name: "Configure rsyslog" + template: + src: templates/rsyslog.conf.j2 + dest: /etc/rsyslog.d/50-{{ service }}.conf + notify: restart rsyslog + +- name: "Configure log rotation" + template: + src: templates/logrotate.conf.j2 + dest: /etc/logrotate.d/{{ service }} diff --git a/tasks/configure-preprocessing-worker.yml b/tasks/configure-preprocessing-worker.yml index 9176562..9eef48e 100644 --- a/tasks/configure-preprocessing-worker.yml +++ b/tasks/configure-preprocessing-worker.yml @@ -1,5 +1,3 @@ ---- - - name: "Create preprocessing shared folder" become: yes file: @@ -52,3 +50,14 @@ path: "/etc/preprocessing-worker.toml" state: absent when: enduro_systemd_credentials|bool + +- name: Configure logging + block: + - include_tasks: configure-logging.yml + vars: + service: "preprocessing-worker" + logfile: "/var/log/enduro/preprocessing-worker.log" + order: "50" + when: enduro_use_syslog|bool + + diff --git a/templates/logrotate.conf.j2 b/templates/logrotate.conf.j2 new file mode 100644 index 0000000..5f22a6e --- /dev/null +++ b/templates/logrotate.conf.j2 @@ -0,0 +1,13 @@ +{{ logfile }} +{ + rotate 7 + daily + missingok + notifempty + delaycompress + compress + postrotate + sudo systemctl reload rsyslog >/dev/null 2>&1 || true + endscript + +} diff --git a/templates/preprocessing-worker.service.j2 b/templates/preprocessing-worker.service.j2 index 328a547..cf16321 100644 --- a/templates/preprocessing-worker.service.j2 +++ b/templates/preprocessing-worker.service.j2 @@ -13,7 +13,11 @@ ExecStart=/usr/bin/preprocessing-worker --config $SECRETS {% else %} ExecStart=/usr/bin/preprocessing-worker --config /etc/preprocessing-worker.toml {% endif %} - +{% if enduro_use_syslog|bool %} +SyslogIdentifier=preprocessing-worker +StandardOutput=syslog +StandardError=inherit +{% endif %} # Let systemd restart this service always #Restart=always diff --git a/templates/rsyslog.conf.j2 b/templates/rsyslog.conf.j2 new file mode 100644 index 0000000..b83fae1 --- /dev/null +++ b/templates/rsyslog.conf.j2 @@ -0,0 +1,13 @@ +if ($programname == "{{ service }}") then { + action( + type="omfile" + FileOwner="enduro" + FileGroup="enduro" + File="{{ logfile }}" + FileCreateMode="0644" + ) + {% if enduro_remote_syslog != "none" %} + *.* @@{{ enduro_remote_syslog }} + {% endif %} + stop +} From 65d2b94732a01acb6d4480ab61a0e50ed4033699 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Rodr=C3=ADguez?= Date: Wed, 15 Jan 2025 15:45:15 +0100 Subject: [PATCH 2/4] Add syslog configuration to enduro-am-worker --- tasks/configure-enduro-am-worker.yml | 10 ++++++++++ templates/enduro-am-worker.service.j2 | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/tasks/configure-enduro-am-worker.yml b/tasks/configure-enduro-am-worker.yml index 540675e..518e6ce 100644 --- a/tasks/configure-enduro-am-worker.yml +++ b/tasks/configure-enduro-am-worker.yml @@ -10,3 +10,13 @@ - templates/{{ inventory_hostname }}/enduro-am-worker.service.j2 - templates/enduro-am-worker.service.j2 notify: restart enduro-am-worker + +- name: Configure logging + block: + - include_tasks: configure-logging.yml + vars: + service: "enduro-am-worker" + logfile: "/var/log/enduro/enduro-am-worker.log" + order: "50" + when: enduro_use_syslog|bool + diff --git a/templates/enduro-am-worker.service.j2 b/templates/enduro-am-worker.service.j2 index ff7988d..f2fb922 100644 --- a/templates/enduro-am-worker.service.j2 +++ b/templates/enduro-am-worker.service.j2 @@ -14,6 +14,11 @@ ExecStart=/usr/bin/enduro-am-worker --config $SECRETS {% else %} ExecStart=/usr/bin/enduro-am-worker --config /etc/enduro.toml {% endif %} +{% if enduro_use_syslog|bool %} +SyslogIdentifier=enduro-am-worker +StandardOutput=syslog +StandardError=inherit +{% endif %} # Let systemd restart this service always #Restart=always From 063e058fc794b3e0f80effd23b49f653fd78bc31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Rodr=C3=ADguez?= Date: Wed, 15 Jan 2025 15:51:05 +0100 Subject: [PATCH 3/4] Add syslog configuration to enduro --- tasks/configure-enduro.yml | 10 ++++++++++ templates/enduro.service.j2 | 7 +++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tasks/configure-enduro.yml b/tasks/configure-enduro.yml index ce61178..efae002 100644 --- a/tasks/configure-enduro.yml +++ b/tasks/configure-enduro.yml @@ -71,3 +71,13 @@ when: - enduro_pipelines|length > 0 - enduro_create_pipeline_transfer_dir|bool + +- name: Configure logging + block: + - include_tasks: configure-logging.yml + vars: + service: "enduro" + logfile: "/var/log/enduro/enduro.log" + order: "50" + when: enduro_use_syslog|bool + diff --git a/templates/enduro.service.j2 b/templates/enduro.service.j2 index 55c4036..1ad0395 100644 --- a/templates/enduro.service.j2 +++ b/templates/enduro.service.j2 @@ -6,13 +6,16 @@ After={{ enduro_systemd_after_services }} Type=simple Restart=on-failure User={{ enduro_system_user }} -SyslogIdentifier=EnduroStdout -SyslogFacility=local1 {% if enduro_systemd_credentials|bool %} ExecStart={{ enduro_binary_install_dir }}/enduro --config $SECRETS {% else %} ExecStart={{ enduro_binary_install_dir }}/enduro --config /etc/enduro.toml {% endif %} +{% if enduro_use_syslog|bool %} +SyslogIdentifier=enduro +StandardOutput=syslog +StandardError=inherit +{% endif %} [Install] WantedBy={{ enduro_systemd_wantedby_services }} From e98e667e8b450db966f2d945447b6c73a0295fcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Rodr=C3=ADguez?= Date: Wed, 15 Jan 2025 18:21:15 +0100 Subject: [PATCH 4/4] Disable colors in stdout/stderr output --- defaults/main.yml | 2 +- templates/preprocessing-worker.toml.j2 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index c5e2a61..b17c9a9 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -9,7 +9,7 @@ enduro_systemd_after_services: "network.target temporal.service" enduro_systemd_wantedby_services: "multi-user.target" enduro_temporal_namespace: "default" # By default only temporal-system namespace exists enduro_debug_verbosity: 2 -enduro_debug_enabled: "true" +enduro_debug_enabled: "false" enduro_listen_temporal_address: "127.0.0.1:7233" enduro_api_debug_enabled: "false" enduro_create_pipeline_transfer_dir: "false" diff --git a/templates/preprocessing-worker.toml.j2 b/templates/preprocessing-worker.toml.j2 index 4a94529..05b6aa4 100644 --- a/templates/preprocessing-worker.toml.j2 +++ b/templates/preprocessing-worker.toml.j2 @@ -1,7 +1,7 @@ {% if enduro_pipelines|length > 0 %} {% set pipeline = enduro_pipelines[0] %} -debug = true +debug = false verbosity = 2 sharedPath = "/var/lib/enduro/preprocessing"