2021-09-29 20:29:58 +08:00
|
|
|
---
|
2024-03-04 21:09:44 +08:00
|
|
|
- name: Collect logs
|
|
|
|
hosts: all
|
|
|
|
become: true
|
2021-09-29 20:29:58 +08:00
|
|
|
tasks:
|
2024-03-04 21:09:44 +08:00
|
|
|
- name: Import_role ceph-defaults
|
|
|
|
ansible.builtin.import_role:
|
2021-09-29 20:29:58 +08:00
|
|
|
name: ceph-defaults
|
|
|
|
|
2024-03-04 21:09:44 +08:00
|
|
|
- name: Import_role ceph-facts
|
|
|
|
ansible.builtin.import_role:
|
2021-09-29 20:29:58 +08:00
|
|
|
name: ceph-facts
|
|
|
|
tasks_from: container_binary.yml
|
|
|
|
|
2024-03-04 21:09:44 +08:00
|
|
|
- name: Import set_radosgw_address.yml
|
|
|
|
ansible.builtin.import_role:
|
2021-09-30 17:32:12 +08:00
|
|
|
name: ceph-facts
|
|
|
|
tasks_from: set_radosgw_address.yml
|
|
|
|
|
2024-03-04 21:09:44 +08:00
|
|
|
- name: Set_fact ceph_cmd
|
|
|
|
ansible.builtin.set_fact:
|
2021-09-29 20:29:58 +08:00
|
|
|
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' }}"
|
|
|
|
|
2024-03-04 21:09:44 +08:00
|
|
|
- name: Get some ceph status outputs
|
|
|
|
ansible.builtin.command: "{{ ceph_cmd }} --connect-timeout 10 --cluster {{ cluster }} {{ item }}"
|
2021-09-29 20:29:58 +08:00
|
|
|
register: ceph_status
|
2024-03-04 21:09:44 +08:00
|
|
|
run_once: true
|
2021-09-29 20:29:58 +08:00
|
|
|
delegate_to: mon0
|
|
|
|
failed_when: false
|
|
|
|
changed_when: false
|
|
|
|
with_items:
|
2021-09-30 14:23:42 +08:00
|
|
|
- "-s -f json-pretty"
|
2021-09-29 20:29:58 +08:00
|
|
|
- "osd tree"
|
|
|
|
- "osd dump"
|
|
|
|
- "pg dump"
|
|
|
|
- "versions"
|
2021-09-30 14:23:42 +08:00
|
|
|
- "health detail -f json-pretty"
|
2021-09-29 20:29:58 +08:00
|
|
|
|
2024-03-04 21:09:44 +08:00
|
|
|
- name: Save ceph status to file
|
|
|
|
ansible.builtin.copy:
|
2021-09-29 20:29:58 +08:00
|
|
|
content: "{{ item.stdout }}"
|
|
|
|
dest: "{{ archive_path }}/{{ item.item | regex_replace(' ', '_') }}.log"
|
|
|
|
delegate_to: localhost
|
2024-03-04 21:09:44 +08:00
|
|
|
run_once: true
|
2021-09-29 20:29:58 +08:00
|
|
|
with_items: "{{ ceph_status.results }}"
|
|
|
|
|
2024-03-04 21:09:44 +08:00
|
|
|
- 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
|
2021-09-29 20:29:58 +08:00
|
|
|
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, []))
|
|
|
|
|
2024-03-04 21:09:44 +08:00
|
|
|
- name: Get rgw log
|
|
|
|
ansible.builtin.shell: journalctl -l -u ceph-radosgw@rgw.{{ ansible_facts['hostname'] }}.{{ item.instance_name }} > /var/log/ceph/ceph-radosgw.{{ ansible_facts['hostname'] }}.{{ item.instance_name }}.log
|
2021-09-30 14:23:42 +08:00
|
|
|
changed_when: false
|
|
|
|
with_items: "{{ rgw_instances | default([]) }}"
|
|
|
|
when: inventory_hostname in groups.get(rgw_group_name, [])
|
|
|
|
|
2024-03-04 21:09:44 +08:00
|
|
|
- name: Find ceph config file and logs
|
|
|
|
ansible.builtin.find:
|
2021-09-29 20:29:58 +08:00
|
|
|
paths:
|
|
|
|
- /etc/ceph
|
|
|
|
- /var/log/ceph
|
|
|
|
patterns:
|
|
|
|
- "*.conf"
|
|
|
|
- "*.log"
|
|
|
|
register: results
|
|
|
|
|
2024-03-04 21:09:44 +08:00
|
|
|
- name: Collect ceph config file and logs
|
|
|
|
ansible.builtin.fetch:
|
2021-09-29 20:29:58 +08:00
|
|
|
src: "{{ item.path }}"
|
|
|
|
dest: "{{ archive_path }}/{{ inventory_hostname }}/"
|
2024-03-04 21:09:44 +08:00
|
|
|
flat: true
|
2021-09-29 20:29:58 +08:00
|
|
|
with_items: "{{ results.files }}"
|