---
# Set up Weave Kube on top of Kubernetes.

- name: set url for weave-kube daemonset
  set_fact:
    weave_kube_url: '{{ (kubernetes_version < "1.6") | ternary("https://git.io/weave-kube", "https://git.io/weave-kube-1.6") }}'

- name: configure weave net's cni plugin
  command: 'kubectl {{ kubeconfig }} apply -f {{ weave_kube_url }}'
  when: '{{ play_hosts[0] == inventory_hostname }}'

- name: list kubernetes' pods
  command: 'kubectl {{ kubeconfig }} get pods --all-namespaces'
  when: '{{ play_hosts[0] == inventory_hostname }}'
  changed_when: false
  register: kubectl_get_pods
  tags:
    - output

- name: print outpout of `kubectl get pods --all-namespaces`
  debug: msg="{{ kubectl_get_pods.stdout_lines }}"
  when: '{{ play_hosts[0] == inventory_hostname }}'
  tags:
    - output
