You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.8 KiB

  1. ---
  2. - hosts: all
  3. become: true
  4. gather_facts: no
  5. vars:
  6. debug: false
  7. commands:
  8. - name: git_info
  9. cmd: find . -type d -name .git -execdir sh -c 'gen-gitinfos.sh global|head -12' \;
  10. - name: timedate_info
  11. cmd: timedatectl status
  12. - name: space_info
  13. cmd: df -h
  14. - name: kernel_info
  15. cmd: uname -r
  16. - name: distro_info
  17. cmd: cat /etc/issue.net
  18. - name: docker_info
  19. cmd: docker info
  20. - name: ip_info
  21. cmd: ip -4 -o a
  22. - name: route_info
  23. cmd: ip ro
  24. - name: proc_info
  25. cmd: ps auxf | grep -v ]$
  26. - name: systemctl_info
  27. cmd: systemctl status
  28. - name: systemctl_failed_info
  29. cmd: systemctl --state=failed --no-pager
  30. - name: k8s_info
  31. cmd: kubectl get all --all-namespaces -o wide
  32. - name: errors_info
  33. cmd: journalctl -p err --utc --no-pager
  34. logs:
  35. - /var/log/ansible.log
  36. - /var/log/ansible/ansible.log
  37. - /var/log/syslog
  38. - /var/log/daemon.log
  39. - /var/log/kern.log
  40. - inventory/inventory.ini
  41. - cluster.yml
  42. tasks:
  43. - name: Storing commands output
  44. shell: "{{ item.cmd }} 2>&1 | tee {{ item.name }}"
  45. register: output
  46. ignore_errors: true
  47. with_items: "{{commands}}"
  48. - debug: var=item
  49. with_items: output.results
  50. when: debug
  51. - name: Fetch results
  52. fetch: src={{ item.name }} dest=/tmp/collect-info/commands
  53. with_items: "{{commands}}"
  54. - name: Fetch logs
  55. fetch: src={{ item }} dest=/tmp/collect-info/logs
  56. with_items: "{{logs}}"
  57. - name: Pack results and logs
  58. local_action: shell GZIP=-9 tar --remove-files -cvzf logs.tar.gz -C /tmp collect-info
  59. run_once: true
  60. - name: Clean up collected command outputs
  61. file: path={{ item.name }} state=absent
  62. with_items: "{{commands}}"