-
Notifications
You must be signed in to change notification settings - Fork 1k
/
collect-logs.yml
81 lines (71 loc) · 2.98 KB
/
collect-logs.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
---
- name: Collect logs
hosts: all
become: true
tasks:
- name: Import_role ceph-defaults
ansible.builtin.import_role:
name: ceph-defaults
- name: Import_role ceph-facts
ansible.builtin.import_role:
name: ceph-facts
tasks_from: container_binary.yml
- name: Import set_radosgw_address.yml
ansible.builtin.import_role:
name: ceph-facts
tasks_from: set_radosgw_address.yml
- name: Set_fact ceph_cmd
ansible.builtin.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
ansible.builtin.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-pretty"
- "osd tree"
- "osd dump"
- "pg dump"
- "versions"
- "health detail -f json-pretty"
- name: Save ceph status to file
ansible.builtin.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 ceph-exporter logs # noqa: ignore-errors
ansible.builtin.shell: journalctl -l -u ceph-exporter@{{ ansible_facts['hostname'] }} | tee -a /var/log/ceph/ceph-exporter.{{ ansible_facts['hostname'] }}.log
changed_when: false
ignore_errors: true
- name: Get mgr log
ansible.builtin.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: Get rgw log
ansible.builtin.shell: journalctl -l -u ceph-radosgw@rgw.{{ rgw_zone }}.{{ ansible_facts['hostname'] }}.{{ item.instance_name }} > /var/log/ceph/ceph-radosgw.{{ ansible_facts['hostname'] }}.{{ item.instance_name }}.log
changed_when: false
with_items: "{{ rgw_instances | default([]) }}"
when: inventory_hostname in groups.get(rgw_group_name, [])
- name: Find ceph config file and logs
ansible.builtin.find:
paths:
- /etc/ceph
- /var/log/ceph
patterns:
- "*.conf"
- "*.log"
register: results
- name: Collect ceph config file and logs
ansible.builtin.fetch:
src: "{{ item.path }}"
dest: "{{ archive_path }}/{{ inventory_hostname }}/"
flat: true
with_items: "{{ results.files }}"