On 07. feb. 2017 19:41, Vikram Ranabhatt wrote:
Here with the following piece of code is waiting for the kubernetest pod to be disappeared after launch. pod do disappeared but the script fails with the error. I want to wait till pod disappeared and the continue with rest of the task.- name: Check ms pod has disappeared sudo: yes run_once: true when: ansible_hostname != "inception-{{ vms_subdomain }}" shell: "kubectl get pod --namespace=vms | grep {{ item.key }}" register: command_res with_dict: "{{ microservices }}" until: "command_res.rc == 1" retries: 10 delay: 20 TASK [sp-sif : Check ms resouce has disappeared] ******************************* Tuesday 07 February 2017 15:26:52 +0000 (0:00:02.051) 0:03:23.889 ****** FAILED - RETRYING: TASK: sp-sif : Check ms resouce has disappeared (5 retries left). FAILED - RETRYING: TASK: sp-sif : Check ms resouce has disappeared (4 retries left). FAILED - RETRYING: TASK: sp-sif : Check ms resouce has disappeared (3 retries left). failed: [kubernetes-master-vik202vmsservices-1] (item={'key': u'iwan', 'value': {u'streams': u'ncs-alarms'}}) => {"attempts": 4, "changed": true, "cmd": "kubectl get pod --namespace=vms | grep iwanms", "del ta": "0:00:00.048855", "end": "2017-02-07 15:28:26.707882", "failed": true, "item": {"key": "iwan", "value": {"streams": "ncs-alarmsf"}}, "rc": 1, "start": "2017-02-07 15:28:26.659027", "stderr": "", "stdout ": "", "stdout_lines": [], "warnings": []}
In Ansible return code greater than 0 is a failure. But you can change that with failed_when: https://docs.ansible.com/ansible/playbooks_error_handling.html#controlling-what-defines-failure You kan use this to make it work: failed_when: command_res.rc > 1 -- Kai Stian Olstad -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d400acf6-39c3-126b-11de-5132fe1694ef%40olstad.com. For more options, visit https://groups.google.com/d/optout.
