mirror of https://github.com/ceph/ceph-ansible.git
82 lines
3.0 KiB
YAML
82 lines
3.0 KiB
YAML
---
|
|
- 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 }}"
|