Collect log from rsyslog container 41/51341/1
authorwutianwei <wutianwei1@huawei.com>
Tue, 30 Jan 2018 06:58:25 +0000 (14:58 +0800)
committerwutianwei <wutianwei1@huawei.com>
Tue, 30 Jan 2018 06:58:25 +0000 (14:58 +0800)
JIRA: COMPASS-579

the script collect-log.sh would be called by releng,
after all the deploy and tests job are complete.

Change-Id: Ic2604ca0650989bc13310377427694ededf75a9d
Signed-off-by: wutianwei <wutianwei1@huawei.com>
deploy/adapters/ansible/roles/config-osa/files/collect-log.sh [new file with mode: 0755]
deploy/adapters/ansible/roles/config-osa/files/collect-log.yml [new file with mode: 0644]
deploy/adapters/ansible/roles/config-osa/tasks/main.yml

diff --git a/deploy/adapters/ansible/roles/config-osa/files/collect-log.sh b/deploy/adapters/ansible/roles/config-osa/files/collect-log.sh
new file mode 100755 (executable)
index 0000000..7f51a2c
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/bash
+##############################################################################
+# Copyright (c) 2018 HUAWEI TECHNOLOGIES CO.,LTD and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+set -o errexit
+set -o nounset
+set -o pipefail
+
+SCRIPT_PATH="$(dirname $(realpath ${BASH_SOURCE[0]}))"
+
+openstack-ansible $SCRIPT_PATH/collect-log.yml
diff --git a/deploy/adapters/ansible/roles/config-osa/files/collect-log.yml b/deploy/adapters/ansible/roles/config-osa/files/collect-log.yml
new file mode 100644 (file)
index 0000000..6e6f9e5
--- /dev/null
@@ -0,0 +1,32 @@
+---
+##############################################################################
+# Copyright (c) 2018 HUAWEI TECHNOLOGIES CO.,LTD and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+- name: Collect log
+  hosts: rsyslog[0]
+  user: root
+  tasks:
+    - name: ensure log directory exist
+      stat:
+        path: /var/log/log-storage
+      register: log_dir
+
+    - name: compress log directory
+      archive:
+        path: "{{ log_dir.stat.path }}"
+        dest: "{{ log_dir.stat.path }}/log.tar.gz"
+        format: gz
+      when: log_dir.stat.exists is defined and log_dir.stat.exists
+
+    - name: fetch the log tarball
+      fetch:
+        src: "{{ log_dir.stat.path }}/log.tar.gz"
+        dest: /opt/log.tar.gz
+        flat: "yes"
+      when: log_dir.stat.exists is defined and log_dir.stat.exists
index f9eef74..a6e9edc 100755 (executable)
   when:
     - "{{ hostvars[inventory_hostname]['groups']['controller'] | length < 2 }}"
 
+- name: copy collect-log.sh to /opt
+  copy:
+    src: collect-log.sh
+    dest: /opt/collect-log.sh
+
+- name: copy collect-log.yml to /opt
+  copy:
+    src: collect-log.yml
+    dest: /opt/collect-log.yml
+
 # - name: change repore build
 #  lineinfile:
 #    dest: /etc/ansible/roles/repo_build/tasks/main.yml