<p>When I deploy <a href="https://projectcontour.io/" rel="nofollow noreferrer">https://projectcontour.io/</a> ingress controller on my Digital Ocean K8S cluster, a load balancer gets created automatically.</p>
<p>I consider to use Ansible as management tool for K8S to automate the deployment.</p>
<p>After the following tasks:</p>
<pre><code>- name: retrieve file
  get_url:
    url: https://projectcontour.io/quickstart/contour.yaml
    dest: /testing/contour.yaml
  register: download_contour

- name: create deployment
  k8s:
    src: /testing/deployment.yml
  when: download_contour.changed
</code></pre>
<p>I would like to wait until the contour gets EXTERNAL-IP address assigned, then continue with other tasks. Here is an example on my local computer:</p>
<pre><code>kubectl get -n projectcontour service envoy -o wide                                                                       
NAME    TYPE           CLUSTER-IP     EXTERNAL-IP      PORT(S)                      AGE     SELECTOR
envoy   LoadBalancer   10.96.226.84   172.18.255.200   80:31092/TCP,443:30362/TCP   2d15h   app=envoy
</code></pre>
<p>How to wait until the <code>envoy</code> LoadBalancer gets the EXTERNAL-IP address assigned in Ansible?</p>

softshipper
<p>I haven't tested it, but I think you could try to do something like this:</p>
<pre><code>- shell: if [[ $(kubectl get services envoy -n projectcontour --output jsonpath='{.status.loadBalancer.ingress[0]}') ]]; then exit 0; else exit 1; fi;
  register: wait_for_ext_ip
  until: wait_for_ext_ip.rc == 0
  retries: 10
  delay: 5
</code></pre>
