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.

79 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']|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-node'][0]}}"
  40. register: agents
  41. retries: 6
  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']|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. delegate_to: "{{groups['kube-node'][0]}}"
  51. run_once: true
  52. - name: Check netchecker status
  53. uri: url=http://localhost:{{netchecker_port}}/api/v1/connectivity_check status_code=200 return_content=yes
  54. delegate_to: "{{groups['kube-node'][0]}}"
  55. run_once: true
  56. register: result
  57. retries: 3
  58. delay: "{{ agent_report_interval }}"
  59. no_log: true
  60. failed_when: false
  61. when: not agents.content=='{}'
  62. - debug: var=result.content|from_json
  63. failed_when: not result|success
  64. delegate_to: "{{groups['kube-node'][0]}}"
  65. run_once: true
  66. when: not agents.content=='{}'
  67. - debug: msg="Cannot get reports from agents, consider as PASSING"
  68. run_once: true
  69. when: agents.content=='{}'