From 11669c211a3e0734b78b2c5472a9bf1e328cbf2f Mon Sep 17 00:00:00 2001 From: Guillaume Abrioux Date: Wed, 29 Sep 2021 14:29:58 +0200 Subject: [PATCH] tests: move collect-logs.yml to ceph-ansible repo related ceph-build PR: ceph/ceph-build#1914 Signed-off-by: Guillaume Abrioux --- tests/functional/collect-logs.yml | 63 +++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 tests/functional/collect-logs.yml diff --git a/tests/functional/collect-logs.yml b/tests/functional/collect-logs.yml new file mode 100644 index 0000000000..389482a554 --- /dev/null +++ b/tests/functional/collect-logs.yml @@ -0,0 +1,63 @@ +--- +- hosts: all + become: yes + tasks: + - name: import_role ceph-defaults + import_role: + name: ceph-defaults + + - name: import_role ceph-facts + import_role: + name: ceph-facts + tasks_from: container_binary.yml + + - name: set_fact ceph_cmd + set_fact: + ceph_cmd: "{{ container_binary + ' run --rm --net=host -v /etc/ceph:/etc/ceph:z -v /var/lib/ceph:/var/lib/ceph:z -v /var/run/ceph:/var/run/ceph:z --entrypoint=ceph ' + ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else 'ceph' }}" + + - name: get some ceph status outputs + command: "{{ ceph_cmd }} --connect-timeout 10 --cluster {{ cluster }} {{ item }}" + register: ceph_status + run_once: True + delegate_to: mon0 + failed_when: false + changed_when: false + with_items: + - "-s -f json" + - "osd tree" + - "osd dump" + - "pg dump" + - "versions" + + - name: save ceph status to file + copy: + content: "{{ item.stdout }}" + dest: "{{ archive_path }}/{{ item.item | regex_replace(' ', '_') }}.log" + delegate_to: localhost + run_once: True + with_items: "{{ ceph_status.results }}" + + - name: get mgr log + shell: journalctl -l -u ceph-mgr@{{ ansible_facts['hostname'] }} > /var/log/ceph/ceph-mgr.{{ ansible_facts['hostname'] }}.log + changed_when: false + when: + - inventory_hostname in groups.get(mgr_group_name, []) + or + (groups.get(mgr_group_name, []) | length == 0 and inventory_hostname in groups.get(mon_group_name, [])) + + - name: find ceph config file and logs + find: + paths: + - /etc/ceph + - /var/log/ceph + patterns: + - "*.conf" + - "*.log" + register: results + + - name: collect ceph config file and logs + fetch: + src: "{{ item.path }}" + dest: "{{ archive_path }}/{{ inventory_hostname }}/" + flat: yes + with_items: "{{ results.files }}"