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.

78 lines
2.7 KiB

  1. ---
  2. - hosts: kube-node
  3. tasks:
  4. - name: Test tunl0 routes
  5. shell: "! /sbin/ip ro | grep '/26 via' | grep -v tunl0"
  6. when: (ipip|default(false) or cloud_provider is defined) and (kube_network_plugin == 'calico')
  7. - hosts: k8s-cluster
  8. vars:
  9. agent_report_interval: 10
  10. netcheck_namespace: default
  11. netchecker_port: 31081
  12. tasks:
  13. - name: Force binaries directory for Container Linux by CoreOS
  14. set_fact:
  15. bin_dir: "/opt/bin"
  16. when: ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
  17. - set_fact:
  18. bin_dir: "/usr/local/bin"
  19. when: not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
  20. - name: Wait for netchecker server
  21. shell: "{{ bin_dir }}/kubectl get pods --namespace {{netcheck_namespace}} | grep ^netchecker-server"
  22. delegate_to: "{{groups['kube-master'][0]}}"
  23. run_once: true
  24. register: ncs_pod
  25. until: ncs_pod.stdout.find('Running') != -1
  26. retries: 3
  27. delay: 10
  28. - name: Wait for netchecker agents
  29. shell: "{{ bin_dir }}/kubectl get pods --namespace {{netcheck_namespace}} | grep '^netchecker-agent-.*Running'"
  30. run_once: true
  31. delegate_to: "{{groups['kube-master'][0]}}"
  32. register: nca_pod
  33. until: "{{ nca_pod.stdout_lines|length }} >= {{ groups['kube-node']|intersect(play_hosts)|length * 2 }}"
  34. retries: 3
  35. delay: 10
  36. - name: Get netchecker agents
  37. uri: url=http://localhost:{{netchecker_port}}/api/v1/agents/ return_content=yes
  38. run_once: true
  39. delegate_to: "{{groups['kube-master'][0]}}"
  40. register: agents
  41. retries: 18
  42. delay: "{{ agent_report_interval }}"
  43. until: "{{ agents.content|length > 0 and
  44. agents.content[0] == '{' and
  45. agents.content|from_json|length >= groups['kube-node']|intersect(play_hosts)|length * 2 }}"
  46. failed_when: false
  47. no_log: true
  48. - debug: var=agents.content|from_json
  49. failed_when: not agents|success and not agents.content=='{}'
  50. run_once: true
  51. - name: Check netchecker status
  52. uri: url=http://localhost:{{netchecker_port}}/api/v1/connectivity_check status_code=200 return_content=yes
  53. delegate_to: "{{groups['kube-master'][0]}}"
  54. run_once: true
  55. register: result
  56. retries: 3
  57. delay: "{{ agent_report_interval }}"
  58. no_log: true
  59. failed_when: false
  60. when: not agents.content=='{}'
  61. - debug: var=result.content|from_json
  62. failed_when: not result|success
  63. run_once: true
  64. when: not agents.content=='{}'
  65. delegate_to: "{{groups['kube-master'][0]}}"
  66. - debug: msg="Cannot get reports from agents, consider as PASSING"
  67. run_once: true
  68. when: agents.content=='{}'