---
  # TODO notify user of the port, ingress
  - name: copy kubernetes-dns.yaml to remote
    template:
      src: kubernetes-dns.yaml
      dest: /tmp/kubernetes-dns.yaml
  - name: start kubernetes-dns service
    command: kubectl apply -f /tmp/kubernetes-dns.yaml
    register: out
  - name: verify kubernetes-dns service is running
    command: kubectl get rc kube-dns-v18 --namespace kube-system -o jsonpath='{.status.readyReplicas}'
    register: readyReplicas
    until: readyReplicas.stdout|int > 0
    retries: 15
    delay: 10

  - debug: var=out.stdout_lines

---
  # TODO notify user of the port, ingress
  - name: copy kubernetes-dns.yaml to remote
    template:
      src: kubernetes-dns.yaml
      dest: /tmp/kubernetes-dns.yaml
  - name: start kubernetes-dns service
    command: kubectl apply -f /tmp/kubernetes-dns.yaml
    register: out
  - name: wait until at least one DNS pod is ready
    command: kubectl get rc kube-dns-v18 --namespace kube-system -o jsonpath='{.status.readyReplicas}'
    register: readyReplicas
    until: readyReplicas.stdout|int > 0
    retries: 15
    delay: 10
    failed_when: false # We don't want this task to actually fail (We catch the failure with a custom msg in the next task)
  - name: verify at least one DNS pod is ready
    fail:
      msg: "Timed out waiting for at least one DNS pod to be in the ready state."
    when: readyReplicas.stdout|int < 1
  - debug: var=out.stdout_lines

Improve error message for DNS failing to start in time
Improve error message for DNS failing to start in time
