0

Here is my Ansible task

- name: wait until response has key word "PIPELINE_STATE_SUCCEEDED"
  uri:
    url: https://abcd.com/response
    method: GET
  register: ABCD 
  until: ABCD.json.state == "PIPELINE_STATE_SUCCEEDED" 
  retries: 30
  delay: 600

When I run this script (total retries and delay adds up to 300 minutes for task to pass), after few retries, suddenly the scripts emits below error message and it breaks.

''dict object'' has no attribute ''state'''

I also tried decreasing delay number and increasing retries but still the same problem. I have several other task in the same playbook which uses similar module except size of delay is significantly less in those (total retries and delay adds up to around 30 minutes).

Any idea why this could be happening?

β.εηοιτ.βε
  • 33,893
  • 13
  • 69
  • 83
quicksilver
  • 289
  • 5
  • 11
  • 3
    Try `until: ABCD.json.state is defined and ABCD.json.state == "PIPELINE_STATE_SUCCEEDED"` – Jack Dec 10 '21 at 22:27
  • 3
    Try ``until: ABCD.json.state|d("NILL") == "PIPELINE_STATE_SUCCEEDED"`` – Vladimir Botka Dec 11 '21 at 01:41
  • @VladimirBotka Thanks for the suggestion but i tried it and it des not work. Using code provided by you, ansible run for entire 300 minutes and but it fails to catch the word "PIPELINE_STATE_SUCCEEDED" , even though it appears after 2.5 hours of run time !! – quicksilver Dec 14 '21 at 15:12
  • @Jack , ran you suggested code, but not working as expected. My script runs for 300 minutes but fails to catch the word "PIPELINE_STATE_SUCCEEDED". – quicksilver Jan 04 '22 at 16:56
  • @quicksilver If your scripts has run 300 minutes, then the Ansible itself is working correctly. You are either looking for the wrong string, or the pipeline is not succeeding. – Jack Jan 04 '22 at 23:53

0 Answers0