Sorry, I wasn't suggesting you use a sequence! :-) That was just to
illustrate the effect in a small test program.

I was just saying that to get the template re-evaluated you need to use a
loop control that changes. Which you have achieved with a check of stdout.

Regards, K.

On Thu, Oct 18, 2018 at 8:33 PM Pavel Martynov <[email protected]> wrote:

> четверг, 18 октября 2018 г., 11:34:25 UTC+3 пользователь Karl Auer написал:
>>
>> Try this:
>>
>> # Test random filter
>> - hosts: localhost
>>
>>   tasks:
>>     - name: Test random
>>       set_fact:
>>          rand_result: "{{ 5 |random }}"
>>       with_sequence: count=10
>>
>> Basically the change of item forces a re-evaluation, even though nothing
>> is changing inside the loop.
>>
>
> I tried to use this:
> - name: Wait DNS A record host.example.com registered
>   set_fact:
>     lookup_result: "{{ lookup('dig', 'host.example.com.') }}"
>   until: lookup_result != 'NXDOMAIN'
>   retries: 1
>   delay: 3
>   with_sequence: count=20
>
> But the overall result of the task is a failure (I think this is because
> there is fail iterations at start).
> Another flaw of this workaround is that task runs all 20 iterations even
> if there is DNS record, say, on 7 iteration (no 'break loop' logic).
>
> I replace my task with this workaround:
> - name: Wait DNS A record host.example.com registered
>   command: "dig host.example.com +short"
>   register: dig_result
>   until: dig_result.stdout != ''
>   retries: 20
>   delay: 3
>
> JFYI there is related issue on Github:
> https://github.com/ansible/ansible/issues/44128
>
>
>>
>> However: You may still have a problem with DNS. A failed lookup
>> (NXDOMAIN) will set a negative cache time on the result; no nameserver will
>> issue a new query until the negative cache time has expired. The negative
>> cache time is commonly set to values between five minutes and a few hours;
>> very stable zones may set higher values. If the zone is under your control
>> - which it looks like it is - set the negative cache time low when you are
>> working on the zone. It's the last field in the SOA.
>>
>>
> Yes, this is private zone under my control and negative cache already set
> to 60 seconds which is fine for me.
>
> --
> 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/d09a4fe9-7e14-4cfe-ac9e-5789399ebd71%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/d09a4fe9-7e14-4cfe-ac9e-5789399ebd71%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Karl Auer

Email  : [email protected]
Website: http://2pisoftware.com

GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA

-- 
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/CA%2B%2BT08QOkLxUoiLfVe4vJYXyvoipt%2Bvz_T5eadG-4aR9Fu_bKQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to