ansible/node: Only do rsyslog config when rsyslog.conf exists
authorMartin Schwenke <martin@meltin.net>
Sun, 15 Aug 2021 06:53:26 +0000 (16:53 +1000)
committerMartin Schwenke <martin@meltin.net>
Wed, 16 Feb 2022 22:40:26 +0000 (09:40 +1100)
On such platforms where rsyslog.conf doesn't exist (e.g. Fedora 34
Vagrant image), assume that logs can be extracted using journalctl.

An alternative would be to attempt to install rsyslog but let's try
this first.

Signed-off-by: Martin Schwenke <martin@meltin.net>
ansible/node/roles/common/tasks/generic/rsyslog.yml
test-ctdb/autocluster-test-ctdb.sh

index 42b828dcc1f286dc517324b82ba65fe99d15a58c..3c13c74f66de94b076d70ce46475a92bf07e8b96 100644 (file)
@@ -1,4 +1,8 @@
 ---
+- name: check for rsyslog.conf
+  stat:
+    path: /etc/rsyslog.conf
+  register: p
 
 # Note that this only configures the high-resolution timestamp format.
 # It doesn't turn off rate limiting (if it defaults to on) and it
@@ -8,6 +12,7 @@
     path: /etc/rsyslog.conf
     regexp: RSYSLOG_TraditionalFileFormat
     replace: RSYSLOG_FileFormat
+  when: p.stat.exists
   notify:
     - restart rsyslog
 
@@ -15,5 +20,6 @@
   copy:
     src: rsyslog.conf
     dest: /etc/rsyslog.d/autocluster.conf
+  when: p.stat.exists
   notify:
     - restart rsyslog
index 86b343ac884c20bad0a8b16f54c2da4c3ce0607a..3e024fb31a7af2dc4dbe8d1a79a5b004ad558ec1 100755 (executable)
@@ -333,7 +333,13 @@ copy_logs ()
        _log_dir="$1"
 
        for _n in $(ssh -n "$ctest_node" onnode -q all hostname) ; do
-               scp -q "${_n}:/var/log/messages" "${_log_dir}/${_n}.messages"
+               _log_file="${_log_dir}/${_n}.messages"
+               if ssh -n "$_n" test -f /var/log/messages ; then
+                       scp -q "${_n}:/var/log/messages" "$_log_file"
+               else
+                       ssh -n "$_n" \
+                           journalctl -q -o short-iso-precise >"$_log_file"
+               fi
        done
 }