Use of --limit crashes the play because of missing facts in the dict

Hi guys,

i have an playbook an its likely to fail with a timeout since i’m targeting ec2.
So i usually retry with the --limit option.

Now the thing is that every host in the play need the address of the provided ‘master’ host. Accessing it with

{{ hostvars[groups[‘master’][0]][‘ansible_fqdn’] }}

But when the master is excluded in a the retry operation because it was successful in the first run, the above code will fail with

{‘msg’: “One or more undefined variables: ‘dict’ object has no attribute ‘ansible_fqdn’”, ‘failed’: True}

Is there any way fixing this without dropping the use of --limit ?

best regards
Johannes

This is a limitation of using limit groups.