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.

94 lines
3.7 KiB

  1. ---
  2. - hosts: all
  3. become: false
  4. gather_facts: no
  5. vars:
  6. commands:
  7. - name: timedate_info
  8. cmd: timedatectl status
  9. - name: kernel_info
  10. cmd: uname -r
  11. - name: docker_info
  12. cmd: docker info
  13. - name: ip_info
  14. cmd: ip -4 -o a
  15. - name: route_info
  16. cmd: ip ro
  17. - name: proc_info
  18. cmd: ps auxf | grep -v ]$
  19. - name: systemctl_failed_info
  20. cmd: systemctl --state=failed --no-pager
  21. - name: k8s_info
  22. cmd: kubectl get all --all-namespaces -o wide
  23. - name: errors_info
  24. cmd: journalctl -p err --no-pager
  25. - name: etcd_info
  26. cmd: etcdctl --debug cluster-health
  27. - name: weave_info
  28. cmd: weave report | jq "."
  29. - name: weave_logs
  30. cmd: docker logs weave
  31. - name: kubedns_logs
  32. cmd: "for i in `kubectl get pods --all-namespaces -l k8s-app=kubedns -o jsonpath={.items..metadata.name}`;
  33. do kubectl logs ${i} --namespace kube-system kubedns; done"
  34. - name: apiserver_logs
  35. cmd: "for i in `kubectl get pods --all-namespaces -l k8s-app=kube-apiserver -o jsonpath={.items..metadata.name}`;
  36. do kubectl logs ${i} --namespace kube-system; done"
  37. - name: controller_logs
  38. cmd: "for i in `kubectl get pods --all-namespaces -l k8s-app=kube-controller -o jsonpath={.items..metadata.name}`;
  39. do kubectl logs ${i} --namespace kube-system; done"
  40. - name: scheduler_logs
  41. cmd: "for i in `kubectl get pods --all-namespaces -l k8s-app=kube-scheduler -o jsonpath={.items..metadata.name}`;
  42. do kubectl logs ${i} --namespace kube-system; done"
  43. - name: proxy_logs
  44. cmd: "for i in `kubectl get pods --all-namespaces -l k8s-app=kube-proxy -o jsonpath={.items..metadata.name}`;
  45. do kubectl logs ${i} --namespace kube-system; done"
  46. - name: nginx_logs
  47. cmd: "for i in `kubectl get pods --all-namespaces -l k8s-app=kube-nginx -o jsonpath={.items..metadata.name}`;
  48. do kubectl logs ${i} --namespace kube-system; done"
  49. - name: flannel_logs
  50. cmd: "for i in `kubectl get pods --all-namespaces -l app=flannel -o jsonpath={.items..metadata.name}`;
  51. do kubectl logs ${i} --namespace kube-system flannel-container; done"
  52. - name: canal_logs
  53. cmd: "for i in `kubectl get pods --all-namespaces -l k8s-app=canal-node -o jsonpath={.items..metadata.name}`;
  54. do kubectl logs ${i} --namespace kube-system flannel; done"
  55. - name: calico_policy_logs
  56. cmd: "for i in `kubectl get pods --all-namespaces -l k8s-app=calico-policy -o jsonpath={.items..metadata.name}`;
  57. do kubectl logs ${i} --namespace kube-system calico-policy-controller; done"
  58. logs:
  59. - /var/log/syslog
  60. - /var/log/daemon.log
  61. - /var/log/kern.log
  62. - /var/log/dpkg.log
  63. - /var/log/apt/history.log
  64. - /var/log/yum.log
  65. - /var/log/calico/bird/current
  66. - /var/log/calico/bird6/current
  67. - /var/log/calico/felix/current
  68. - /var/log/calico/confd/current
  69. tasks:
  70. - name: Storing commands output
  71. shell: "{{ item.cmd }} 2>&1 | tee {{ item.name }}"
  72. register: output
  73. ignore_errors: true
  74. with_items: "{{commands}}"
  75. no_log: True
  76. - name: Fetch results
  77. fetch: src={{ item.name }} dest=/tmp/collect-info/commands
  78. with_items: "{{commands}}"
  79. - name: Fetch logs
  80. fetch: src={{ item }} dest=/tmp/collect-info/logs
  81. with_items: "{{logs}}"
  82. - name: Pack results and logs
  83. local_action: shell GZIP=-9 tar --remove-files -cvzf {{dir|default(".")}}/logs.tar.gz -C /tmp collect-info
  84. run_once: true
  85. - name: Clean up collected command outputs
  86. file: path={{ item.name }} state=absent
  87. with_items: "{{commands}}"