From a8892ecc55b5fd4138ed495224c3f9f8f696a2c1 Mon Sep 17 00:00:00 2001 From: Sai Sindhur Malleni Date: Fri, 27 Jul 2018 15:48:08 +0530 Subject: [PATCH] Add opendaylight log collection Change-Id: Idb4eaf8bd89473a761919dab14a02b0fa0cf8fc6 --- ansible/logs/get-overcloud-logs.yml | 1 + .../logs/roles/opendaylight/tasks/main.yml | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 ansible/logs/roles/opendaylight/tasks/main.yml diff --git a/ansible/logs/get-overcloud-logs.yml b/ansible/logs/get-overcloud-logs.yml index d50db28cf..a7bbe5579 100644 --- a/ansible/logs/get-overcloud-logs.yml +++ b/ansible/logs/get-overcloud-logs.yml @@ -28,6 +28,7 @@ - rabbitmq - httpd - openvswitch + - opendaylight - common - fetch-logs diff --git a/ansible/logs/roles/opendaylight/tasks/main.yml b/ansible/logs/roles/opendaylight/tasks/main.yml new file mode 100644 index 000000000..162b1c2a7 --- /dev/null +++ b/ansible/logs/roles/opendaylight/tasks/main.yml @@ -0,0 +1,33 @@ +--- +- name: Check that opendaylight is installed + stat: + path: /opt/opendaylight + register: opendaylight_baremetal + +- name: Check if opendaylight is containerized + stat: + path: /var/lib/config-data/puppet-generated/opendaylight + register: opendaylight_container + +- name: Set opendaylight log location (containerized) + set_fact: + opendaylight_logs: /var/log/containers/opendaylight + when: opendaylight_container.stat.isdir is defined and opendaylight_container.stat.isdir + +- name: Set opendaylight location (non-containerized) + set_fact: + opendaylight_logs: /opt/opendaylight/data/logs + when: opendaylight_baremetal.stat.isdir is defined and opendaylight_baremetal.stat.isdir + +- name: Check if log folder exists + stat: + path: "{{opendaylight_logs}}" + register: logs_path + +- name: Copy logs to directory on host + synchronize: + src: "{{opendaylight_logs}}" + dest: /home/{{host_remote_user}}/{{ansible_hostname}} + delegate_to: "{{ inventory_hostname }}" + when: (opendaylight_baremetal or opendaylight_container) and logs_path.stat.isdir is defined and logs_path.stat.isdir +