--- - name: Get laravelio Service Info kubernetes.core.k8s_info: api_version: v1 kind: Service namespace: default label_selectors: - "app=laravelio" register: service_info until: service_facts.resources[0].status.loadBalancer.ingress[0].ip is defined retries: 60 delay: 10 - name: Store app_ip set_fact: app_ip: "{{ service_facts.resources[0].status.loadBalancer.ingress[0].ip }}" - name: Update app_ip in Inventory lineinfile: path: inventory/gcp.yml regexp: '^ app_ip: (.*)$' line: ' app_ip: {{ app_ip }}' backrefs: yes - name: Refresh Inventory meta: refresh_inventory