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.

102 lines
4.0 KiB

  1. ---
  2. - hosts: all
  3. become: true
  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 --peers={{ etcd_access_addresses }} cluster-health
  27. - name: weave_info
  28. cmd: weave report
  29. - name: weave_logs
  30. cmd: docker logs weave
  31. - name: kube_describe_all
  32. cmd: kubectl describe all --all-namespaces
  33. - name: kubedns_logs
  34. cmd: "for i in `kubectl get pods --all-namespaces -l k8s-app=kubedns -o jsonpath={.items..metadata.name}`;
  35. do kubectl logs ${i} --namespace kube-system kubedns; done"
  36. - name: apiserver_logs
  37. cmd: "for i in `kubectl get pods --all-namespaces -l k8s-app=kube-apiserver -o jsonpath={.items..metadata.name}`;
  38. do kubectl logs ${i} --namespace kube-system; done"
  39. - name: controller_logs
  40. cmd: "for i in `kubectl get pods --all-namespaces -l k8s-app=kube-controller -o jsonpath={.items..metadata.name}`;
  41. do kubectl logs ${i} --namespace kube-system; done"
  42. - name: scheduler_logs
  43. cmd: "for i in `kubectl get pods --all-namespaces -l k8s-app=kube-scheduler -o jsonpath={.items..metadata.name}`;
  44. do kubectl logs ${i} --namespace kube-system; done"
  45. - name: proxy_logs
  46. cmd: "for i in `kubectl get pods --all-namespaces -l k8s-app=kube-proxy -o jsonpath={.items..metadata.name}`;
  47. do kubectl logs ${i} --namespace kube-system; done"
  48. - name: nginx_logs
  49. cmd: "for i in `kubectl get pods --all-namespaces -l k8s-app=kube-nginx -o jsonpath={.items..metadata.name}`;
  50. do kubectl logs ${i} --namespace kube-system; done"
  51. - name: flannel_logs
  52. cmd: "for i in `kubectl get pods --all-namespaces -l app=flannel -o jsonpath={.items..metadata.name}`;
  53. do kubectl logs ${i} --namespace kube-system flannel-container; done"
  54. - name: canal_logs
  55. cmd: "for i in `kubectl get pods --all-namespaces -l k8s-app=canal-node -o jsonpath={.items..metadata.name}`;
  56. do kubectl logs ${i} --namespace kube-system flannel; done"
  57. - name: calico_policy_logs
  58. cmd: "for i in `kubectl get pods --all-namespaces -l k8s-app=calico-policy -o jsonpath={.items..metadata.name}`;
  59. do kubectl logs ${i} --namespace kube-system calico-policy-controller; done"
  60. logs:
  61. - /var/log/syslog
  62. - /var/log/daemon.log
  63. - /var/log/kern.log
  64. - /var/log/dpkg.log
  65. - /var/log/apt/history.log
  66. - /var/log/yum.log
  67. - /var/log/calico/bird/current
  68. - /var/log/calico/bird6/current
  69. - /var/log/calico/felix/current
  70. - /var/log/calico/confd/current
  71. tasks:
  72. - set_fact:
  73. etcd_access_addresses: |-
  74. {% for item in groups['etcd'] -%}
  75. https://{{ item }}:2379{% if not loop.last %},{% endif %}
  76. {%- endfor %}
  77. - name: Storing commands output
  78. shell: "{{ item.cmd }} 2>&1 | tee {{ item.name }}"
  79. register: output
  80. ignore_errors: true
  81. with_items: "{{commands}}"
  82. no_log: True
  83. - name: Fetch results
  84. fetch: src={{ item.name }} dest=/tmp/collect-info/commands
  85. with_items: "{{commands}}"
  86. - name: Fetch logs
  87. fetch: src={{ item }} dest=/tmp/collect-info/logs
  88. with_items: "{{logs}}"
  89. - name: Pack results and logs
  90. local_action: raw GZIP=-9 tar --remove-files -cvzf {{dir|default(".")}}/logs.tar.gz -C /tmp collect-info
  91. run_once: true
  92. - name: Clean up collected command outputs
  93. file: path={{ item.name }} state=absent
  94. with_items: "{{commands}}"