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.

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