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.

30 lines
813 B

  1. ---
  2. - hosts: node1
  3. tasks:
  4. - name: Force binaries directory for CoreOS
  5. set_fact:
  6. bin_dir: "/opt/bin"
  7. when: ansible_os_family == "CoreOS"
  8. - set_fact:
  9. bin_dir: "/usr/local/bin"
  10. when: ansible_os_family != "CoreOS"
  11. - name: Get pod names
  12. shell: "{{bin_dir}}/kubectl get pods -o json"
  13. register: pods
  14. - set_fact:
  15. pod_names: "{{ (pods.stdout | from_json)['items'] | map(attribute = 'metadata.name') | list }}"
  16. pod_ips: "{{ (pods.stdout | from_json)['items'] | map(attribute = 'status.podIP') | list }}"
  17. - name: Check pods IP are in correct network
  18. assert:
  19. that: item | ipaddr(kube_pods_subnet)
  20. with_items: "{{pod_ips}}"
  21. - name: Ping between pods is working
  22. shell: "{{bin_dir}}/kubectl exec {{pod_names[0]}} -- ping -c 4 {{ pod_ips[1] }}"