From 68b619f36911eaf3deef8b8a3ec1ec655e86adf7 Mon Sep 17 00:00:00 2001 From: wutianwei Date: Tue, 30 Jan 2018 14:58:25 +0800 Subject: Collect log from rsyslog container 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 --- .../ansible/roles/config-osa/files/collect-log.sh | 17 ++++++++++++ .../ansible/roles/config-osa/files/collect-log.yml | 32 ++++++++++++++++++++++ .../ansible/roles/config-osa/tasks/main.yml | 10 +++++++ 3 files changed, 59 insertions(+) create mode 100755 deploy/adapters/ansible/roles/config-osa/files/collect-log.sh create mode 100644 deploy/adapters/ansible/roles/config-osa/files/collect-log.yml (limited to 'deploy/adapters/ansible') 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 index 00000000..7f51a2c3 --- /dev/null +++ b/deploy/adapters/ansible/roles/config-osa/files/collect-log.sh @@ -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 index 00000000..6e6f9e5a --- /dev/null +++ b/deploy/adapters/ansible/roles/config-osa/files/collect-log.yml @@ -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 diff --git a/deploy/adapters/ansible/roles/config-osa/tasks/main.yml b/deploy/adapters/ansible/roles/config-osa/tasks/main.yml index f9eef749..a6e9edc5 100755 --- a/deploy/adapters/ansible/roles/config-osa/tasks/main.yml +++ b/deploy/adapters/ansible/roles/config-osa/tasks/main.yml @@ -332,6 +332,16 @@ 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 -- cgit 1.2.3-korg